Writing an equivalent Julia mutable struct that have similar functionality of a Python class

This seems very similar to your prior question:

It would be great if you could attempt the Julia solution given the prior knowledge and show us your attempt in the future.

julia> let counter = 0
           global Foo
           Base.@kwdef mutable struct Foo
               bar::Bool
               baz::Any
               counter::Union{Int, Nothing}
               dict::Dict
           end
               function Foo(;bar=true, dict=Dict{Foo,Int}())
                   self = Foo(bar, nothing, nothing, dict)
                   if bar
                       self.dict = Dict(self => 1)
                       self.counter = counter
                       counter += 1
                   end
                   return self
               end
       end
Foo

julia> Base.show(io::IO, f::Foo) =
           print(io, """
           Foo(
               bar=$(f.bar),
               baz=$(f.baz),
               dict=$(f.bar ?
                   "Dict(#=circular reference=# => 1)" :
                   f.dict
               ),
               counter=$(f.counter)
           )""")

julia> foo1 = Foo()
Foo(
    bar=true,
    baz=nothing,
    dict=Dict(#=circular reference=# => 1),
    counter=0
)

julia> custom_dict = Dict('a' => 1, 'b' => 2)
Dict{Char, Int64} with 2 entries:
  'a' => 1
  'b' => 2

julia> foo2 = Foo(bar=false, dict=custom_dict)
Foo(
    bar=false,
    baz=nothing,
    dict=Dict('a' => 1, 'b' => 2),
    counter=nothing
)

julia> foo3 = Foo(); @show foo3;
foo3 = Foo(
    bar=true,
    baz=nothing,
    dict=Dict(#=circular reference=# => 1),
    counter=1
)