问:
How can I concatenate tensors of different shape for LSTM training?
I am struggling with the following situation: I have to train a LSTM to generate series of bank transactions, and to do that I would also like to insert in the LSTM some information about the subject performing the operations. My ultimate goal, after the training, would be to feed the LSTM with a vector containing the info about a subject, possibly a first operation, and then generate a sequence of operations.

Now, my doubt is the following: since the information about the subject is a 1-row tensor, while the sequence of operations (of variable length) is of multiple rows and different features, therefore the two tensors have different shapes. How can they be concatenated together and how should they be fed into the network?

Let’s say I have:

subj_info = torch.tensor([26., 0., 1., 0.])   # tensor containing a bunch of info about the user

operation_series = tensor([[0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00],
                           [0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00],
                           [0.0000e+00, 4.6638e-04, 2.2581e-02, 0.0000e+00],
                           [0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00],
                           [0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00],
                           [0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00],
                           [1.0000e+00, 2.6664e-03, 0.0000e+00, 1.0000e+00],
                           [0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00],
                           [1.0000e+00, 1.9997e-03, 0.0000e+00, 1.0000e+00],
                           [1.0000e+00, 3.4416e-04, 0.0000e+00, 1.0000e+00],
                           [1.0000e+00, 6.6638e-04, 0.0000e+00, 1.0000e+00],
                           [1.0000e+00, 9.9972e-04, 0.0000e+00, 1.0000e+00],
                           [0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00],
                           [0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00])
             # 2D tensor with l operations, each with n features

```
<p>I would like to concatenate the two tensors to feed them into the LSTM, so that the network learns the sequences but also the info associated to the subject.</p>
<p>I already tried:</p>
```torch.cat([subj_info.unsqueeze(0), operation_series.unsqueeze(0)], dim=0)
```
<p>but it doesn’t work because they have different shapes, not even creating a new dimension and concatenating along that, and neither torch.stack did the trick for me. Am I doing something wrong with the dimensions of the tensors?</p>
<p>For the moment I am concatenating the subj_info to the whole list of operations so my input data is:</p>
<pre class="lang-py prettyprint-override"><code>

input = tensor([[26., 0., 1., 0., 0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00],
               [26., 0., 1., 0., 0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00],
               [26., 0., 1., 0., 0.0000e+00, 4.6638e-04, 2.2581e-02, 0.0000e+00],
               [26., 0., 1., 0., 0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00],
               [26., 0., 1., 0., 0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00],
               [26., 0., 1., 0., 0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00],
               [26., 0., 1., 0., 1.0000e+00, 2.6664e-03, 0.0000e+00, 1.0000e+00],
               [26., 0., 1., 0., 0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00],
               [26., 0., 1., 0., 1.0000e+00, 1.9997e-03, 0.0000e+00, 1.0000e+00],
               [26., 0., 1., 0., 1.0000e+00, 3.4416e-04, 0.0000e+00, 1.0000e+00],
               [26., 0., 1., 0., 1.0000e+00, 6.6638e-04, 0.0000e+00, 1.0000e+00],
               [26., 0., 1., 0., 1.0000e+00, 9.9972e-04, 0.0000e+00, 1.0000e+00],
               [26., 0., 1., 0., 0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00],
               [26., 0., 1., 0., 0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00])

</code>```

but I don’t think this is optimal, because the LSTM won’t learn correctly the features about the operations.

Moreover, let's say I manage to concatenate them so that I have something like:

```<code>tensor[ [subj_info] ,[ [....]
                       [....]
                       [....]
                         ..
                       [....] ] ]
</code>```

How should I use such input for the LSTM if I want it to "focus" only on the operation sequence?

Thanks to everyone who can help.

Body:
I am struggling with the following situation: I have to train a LSTM to generate series of bank transactions, and to do that I would also like to insert in the LSTM some information about the subject performing the operations. My ultimate goal, after the training, would be to feed the LSTM with a vector containing the info about a subject, possibly a first operation, and then generate a sequence of operations.

Now, my doubt is the following: since the information about the subject is a 1-row tensor, while the sequence of operations (of variable length) is of multiple rows and different features, therefore the two tensors have different shapes. How can they be concatenated together and how should they be fed into the network?

Let’s say I have:

subj_info = torch.tensor([26., 0., 1., 0.])   # tensor containing a bunch of info about the user

operation_series = tensor([[0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00],
                           [0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00],
                           [0.0000e+00, 4.6638e-04, 2.2581e-02, 0.0000e+00],
                           [0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00],
                           [0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00],
                           [0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00],
                           [1.0000e+00, 2.6664e-03, 0.0000e+00, 1.0000e+00],
                           [0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00],
                           [1.0000e+00, 1.9997e-03, 0.0000e+00, 1.0000e+00],
                           [1.0000e+00, 3.4416e-04, 0.0000e+00, 1.0000e+00],
                           [1.0000e+00, 6.6638e-04, 0.0000e+00, 1.0000e+00],
                           [1.0000e+00, 9.9972e-04, 0.0000e+00, 1.0000e+00],
                           [0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00],
                           [0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00])
             # 2D tensor with l operations, each with n features

I would like to concatenate the two tensors to feed them into the LSTM, so that the network learns the sequences but also the info associated to the subject.

I already tried:

torch.cat([subj_info.unsqueeze(0), operation_series.unsqueeze(0)], dim=0)

but it doesn’t work because they have different shapes, not even creating a new dimension and concatenating along that, and neither torch.stack did the trick for me. Am I doing something wrong with the dimensions of the tensors?

For the moment I am concatenating the subj_info to the whole list of operations so my input data is:

input = tensor([[26., 0., 1., 0., 0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00],
               [26., 0., 1., 0., 0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00],
               [26., 0., 1., 0., 0.0000e+00, 4.6638e-04, 2.2581e-02, 0.0000e+00],
               [26., 0., 1., 0., 0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00],
               [26., 0., 1., 0., 0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00],
               [26., 0., 1., 0., 0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00],
               [26., 0., 1., 0., 1.0000e+00, 2.6664e-03, 0.0000e+00, 1.0000e+00],
               [26., 0., 1., 0., 0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00],
               [26., 0., 1., 0., 1.0000e+00, 1.9997e-03, 0.0000e+00, 1.0000e+00],
               [26., 0., 1., 0., 1.0000e+00, 3.4416e-04, 0.0000e+00, 1.0000e+00],
               [26., 0., 1., 0., 1.0000e+00, 6.6638e-04, 0.0000e+00, 1.0000e+00],
               [26., 0., 1., 0., 1.0000e+00, 9.9972e-04, 0.0000e+00, 1.0000e+00],
               [26., 0., 1., 0., 0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00],
               [26., 0., 1., 0., 0.0000e+00, 3.3305e-04, 1.6129e-02, 0.0000e+00])

but I don’t think this is optimal, because the LSTM won’t learn correctly the features about the operations.

Moreover, let's say I manage to concatenate them so that I have something like:

tensor[ [subj_info] ,[ [....]
                       [....]
                       [....]
                         ..
                       [....] ] ]

How should I use such input for the LSTM if I want it to "focus" only on the operation sequence?

Thanks to everyone who can help.


来源: stackexchange

问:
Jest cannot import typescript module after environment is setup
When starting my application with jest in setupFilesAfterEnv I get an error

Error: Cannot find module 'C:\Users\User\projects\service\packages\app\lib\migration\1'
Require stack:
- C:\Users\User\projects\service\node_modules\.pnpm\@uus+mongo-database@3.1.0\node_modules\@uus\mongo-database\lib\migration\migrations\base\MigratorProvider.js
- C:\Users\User\projects\service\node_modules\.pnpm\@uus+mongo-database@3.1.0\node_modules\@uus\mongo-database\index.js
- C:\Users\User\projects\service\node_modules\.pnpm\@uus+graphql-server@6.0.3_nr3tp6blc4itofcxasmnc2fbqm\node_modules\@uus\graphql-server\lib\utils\filters\GraphQLObjectIdFilter.js
- C:\Users\User\projects\service\node_modules\.pnpm\@uus+graphql-server@6.0.3_nr3tp6blc4itofcxasmnc2fbqm\node_modules\@uus\graphql-server\index.js
- C:\Users\User\projects\service\packages\app\lib\App.app.ts
- C:\Users\User\projects\service\__tests__\lib\setup.jest.ts
- C:\Users\User\projects\service\node_modules\.pnpm\jest-util@29.3.1\node_modules\jest-util\build\requireOrImportModule.js
- C:\Users\User\projects\service\node_modules\.pnpm\jest-util@29.3.1\node_modules\jest-util\build\index.js
- C:\Users\User\projects\service\node_modules\.pnpm\jest-config@29.3.1\node_modules\jest-config\build\getCacheDirectory.js
- C:\Users\User\projects\service\node_modules\.pnpm\jest-config@29.3.1\node_modules\jest-config\build\Defaults.js
- C:\Users\User\projects\service\node_modules\.pnpm\jest-config@29.3.1\node_modules\jest-config\build\normalize.js
- C:\Users\User\projects\service\node_modules\.pnpm\jest-config@29.3.1\node_modules\jest-config\build\index.js
- C:\Users\User\projects\service\node_modules\.pnpm\jest-cli@29.3.1\node_modules\jest-cli\build\init\index.js
- C:\Users\User\projects\service\node_modules\.pnpm\jest-cli@29.3.1\node_modules\jest-cli\build\run.js
- C:\Users\User\projects\service\node_modules\.pnpm\jest-cli@29.3.1\node_modules\jest-cli\build\index.js
- C:\Users\User\projects\service\node_modules\.pnpm\jest-cli@29.3.1\node_modules\jest-cli\bin\jest.js
- C:\Users\User\projects\service\node_modules\.pnpm\jest@29.3.1\node_modules\jest\bin\jest.js

    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:101:18)
    at loadMigratorFromFile (C:\Users\User\projects\service\node_modules\.pnpm\@uus+mongo-database@3.1.0\node_modules\@uus\mongo-database\lib\migration\migrations\base\MigratorProvider.ts:13:40)
    at MigrationProvider.start (C:\Users\User\projects\service\node_modules\.pnpm\@uus+mongo-database@3.1.0\node_modules\@uus\mongo-database\lib\migration\MigrationProvider.ts:57:58)
    at App.start (C:\Users\User\projects\service\packages\app\lib\App.app.ts:103:9)
    at Object.<anonymous> (C:\Users\User\projects\service\packages\app\lib\__tests__\startup.integ.spec.new.ts:14:5)
```
<p>I have the following statement in the startup code for the database migration:</p>
<pre class="lang-js prettyprint-override"><code>function loadMigratorFromFile(filePath) {
    // eslint-disable-next-line import/no-dynamic-require,global-require
    const { default: MigratorClass } = require(filePath);
    return MigratorClass;
}
</code>```

filePath has the value C:\Users\User\projects\service\packages\app\lib\migration\1 which points to a folder 1 with a single file named index.ts. The content of that file is

@injectable()
export default class V1Migrator extends Migrator {
    constructor(protected readonly _provider: Provider) {
        super();
    }

    protected async _run(): Promise<void> {
        this._logger.info('Started migration');
        await this._provider.requestDao.updateMany(
            { type: { $exists: false } },
            { $set: { 'type.type': 'DEFAULT' } }
        );
        this._logger.info('Stopped migration');
    }
}
```
<p>When I start my application in jests <code>globalSetup</code> I don't have the error. But I need to mock some imports in the startup file of my Application so I have to start it after jest set up the environment.</p>
<p>Full jest config:</p>

```"jest": {
  "preset": "ts-jest",
  "testEnvironment": "node",
  "testMatch": [
    "**/__tests__/**/*.spec.new.ts?(x)"
  ],
  "globalSetup": "./__tests__/lib/setup.jest.ts",
  "setupFilesAfterEnv": ["./__tests__/lib/startAppAfterEnv.jest.ts"],
  "globalTeardown": "./__tests__/lib/teardown.jest.ts",
  "setupFiles": [
    "./setupTests.ts"
  ]
},
```
<p>App gets started in <code>./__tests__/lib/startAppAfterEnv.jest.ts</code> starting it in <code>./__tests__/lib/setup.jest.ts</code> would get the import to function but like I said not the mocking.</p>
<p>I tried setting the option <code>"moduleFileExtensions": ["ts", "js", "mjs", "cjs", "jsx", "tsx", "json", "node"]</code> and <code>"modulePaths": ["<rootDir>/packages/"],</code> without success.</p>
<p><code>console.log(require.extensions)</code> in <code>setup.jest.ts</code> gives</p>
<pre class="lang-js prettyprint-override"><code>[Object: null prototype] {
  '.js': [Function: newLoader],
  '.json': [Function: newLoader],
  '.node': [Function: newLoader],
  '.cjs': [Function: newLoader],
  '.jsx': [Function: newLoader],
  '.ts': [Function: newLoader],
  '.tsx': [Function: newLoader]
}
</code>```

while in startAppAfterEnv.jest.ts it only gives

[Object: null prototype] {}
```

ContentLicense: CC BY-SA 4.0

Body:
When starting my application with jest in setupFilesAfterEnv I get an error

Error: Cannot find module 'C:\Users\User\projects\service\packages\app\lib\migration\1'
Require stack:
- C:\Users\User\projects\service\node_modules\.pnpm\@uus+mongo-database@3.1.0\node_modules\@uus\mongo-database\lib\migration\migrations\base\MigratorProvider.js
- C:\Users\User\projects\service\node_modules\.pnpm\@uus+mongo-database@3.1.0\node_modules\@uus\mongo-database\index.js
- C:\Users\User\projects\service\node_modules\.pnpm\@uus+graphql-server@6.0.3_nr3tp6blc4itofcxasmnc2fbqm\node_modules\@uus\graphql-server\lib\utils\filters\GraphQLObjectIdFilter.js
- C:\Users\User\projects\service\node_modules\.pnpm\@uus+graphql-server@6.0.3_nr3tp6blc4itofcxasmnc2fbqm\node_modules\@uus\graphql-server\index.js
- C:\Users\User\projects\service\packages\app\lib\App.app.ts
- C:\Users\User\projects\service\__tests__\lib\setup.jest.ts
- C:\Users\User\projects\service\node_modules\.pnpm\jest-util@29.3.1\node_modules\jest-util\build\requireOrImportModule.js
- C:\Users\User\projects\service\node_modules\.pnpm\jest-util@29.3.1\node_modules\jest-util\build\index.js
- C:\Users\User\projects\service\node_modules\.pnpm\jest-config@29.3.1\node_modules\jest-config\build\getCacheDirectory.js
- C:\Users\User\projects\service\node_modules\.pnpm\jest-config@29.3.1\node_modules\jest-config\build\Defaults.js
- C:\Users\User\projects\service\node_modules\.pnpm\jest-config@29.3.1\node_modules\jest-config\build\normalize.js
- C:\Users\User\projects\service\node_modules\.pnpm\jest-config@29.3.1\node_modules\jest-config\build\index.js
- C:\Users\User\projects\service\node_modules\.pnpm\jest-cli@29.3.1\node_modules\jest-cli\build\init\index.js
- C:\Users\User\projects\service\node_modules\.pnpm\jest-cli@29.3.1\node_modules\jest-cli\build\run.js
- C:\Users\User\projects\service\node_modules\.pnpm\jest-cli@29.3.1\node_modules\jest-cli\build\index.js
- C:\Users\User\projects\service\node_modules\.pnpm\jest-cli@29.3.1\node_modules\jest-cli\bin\jest.js
- C:\Users\User\projects\service\node_modules\.pnpm\jest@29.3.1\node_modules\jest\bin\jest.js

    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:101:18)
    at loadMigratorFromFile (C:\Users\User\projects\service\node_modules\.pnpm\@uus+mongo-database@3.1.0\node_modules\@uus\mongo-database\lib\migration\migrations\base\MigratorProvider.ts:13:40)
    at MigrationProvider.start (C:\Users\User\projects\service\node_modules\.pnpm\@uus+mongo-database@3.1.0\node_modules\@uus\mongo-database\lib\migration\MigrationProvider.ts:57:58)
    at App.start (C:\Users\User\projects\service\packages\app\lib\App.app.ts:103:9)
    at Object.<anonymous> (C:\Users\User\projects\service\packages\app\lib\__tests__\startup.integ.spec.new.ts:14:5)

I have the following statement in the startup code for the database migration:

function loadMigratorFromFile(filePath) {
    // eslint-disable-next-line import/no-dynamic-require,global-require
    const { default: MigratorClass } = require(filePath);
    return MigratorClass;
}

filePath has the value C:\Users\User\projects\service\packages\app\lib\migration\1 which points to a folder 1 with a single file named index.ts. The content of that file is

@injectable()
export default class V1Migrator extends Migrator {
    constructor(protected readonly _provider: Provider) {
        super();
    }

    protected async _run(): Promise<void> {
        this._logger.info('Started migration');
        await this._provider.requestDao.updateMany(
            { type: { $exists: false } },
            { $set: { 'type.type': 'DEFAULT' } }
        );
        this._logger.info('Stopped migration');
    }
}

When I start my application in jests globalSetup I don't have the error. But I need to mock some imports in the startup file of my Application so I have to start it after jest set up the environment.

Full jest config:

"jest": {
  "preset": "ts-jest",
  "testEnvironment": "node",
  "testMatch": [
    "**/__tests__/**/*.spec.new.ts?(x)"
  ],
  "globalSetup": "./__tests__/lib/setup.jest.ts",
  "setupFilesAfterEnv": ["./__tests__/lib/startAppAfterEnv.jest.ts"],
  "globalTeardown": "./__tests__/lib/teardown.jest.ts",
  "setupFiles": [
    "./setupTests.ts"
  ]
},

App gets started in ./__tests__/lib/startAppAfterEnv.jest.ts starting it in ./__tests__/lib/setup.jest.ts would get the import to function but like I said not the mocking.

I tried setting the option "moduleFileExtensions": ["ts", "js", "mjs", "cjs", "jsx", "tsx", "json", "node"] and "modulePaths": ["<rootDir>/packages/"], without success.

console.log(require.extensions) in setup.jest.ts gives

[Object: null prototype] {
  '.js': [Function: newLoader],
  '.json': [Function: newLoader],
  '.node': [Function: newLoader],
  '.cjs': [Function: newLoader],
  '.jsx': [Function: newLoader],
  '.ts': [Function: newLoader],
  '.tsx': [Function: newLoader]
}

while in startAppAfterEnv.jest.ts it only gives

[Object: null prototype] {}


问:
GluonTS SimpleFeedForward Estimator Loss Values
I am using the GluonTS package to produce some probabilistic forecasts on a small dataset (60 observations, 57 training, and 3 test). The reason I have selected the GluonTS is other packages were not really successful to produce some reasonable results.

To be on the safe side, I am using Simple Feed Forward and I have only 10 epochs but after the 6th epoch, I saw that the error is not decreasing as in the screenshot:

Is this overfitting? Because when I decrease the epochs to 5 or 6 the test results are not that good. Can I keep 10 epochs even in this kind of situation? Or is it wrong to use 10 epochs? When I increase the epochs up to 100, I see that it keeps decreasing.

Thanks and Regards.


问:
how to use rtl mode in react-native-reanimated-carousel
i'm trying to use this react-native-reanimated-carousel in my project, i need the carousel direction to be rtl but i just can't achieve that, it mentions on the npm page that rtl mode is supported, how can i achieve it?

i just want a normal horizontal carousel with direction as rtl

i also tried the modeConfig options object where i changed the snapDirection but that didn't also work.

here is my code

```<code>
function PagesContainer({ currentPageNumber, setCurrentPageNumber }) {
    const width = Dimensions.get('window').width;
    let pageComponents = [<Comp />, <Comp />, <Comp />, <Comp />]
    }
    return (<Carousel
        width={width}
        height={width * 2}
        autoPlay={false}
        loop={false}
        data={pageComponents}
        defaultIndex={currentPageNumber == 1 ? 0 : 1}
        modeConfig={{ snapDirection: 'right' }}
        renderItem={({ index }) => {
            return pageComponents[index];
        }}
    />)
}

</code>```

Body:
i'm trying to use this react-native-reanimated-carousel in my project, i need the carousel direction to be rtl but i just can't achieve that, it mentions on the npm page that rtl mode is supported, how can i achieve it?

i just want a normal horizontal carousel with direction as rtl

i also tried the modeConfig options object where i changed the snapDirection but that didn't also work.

here is my code

function PagesContainer({ currentPageNumber, setCurrentPageNumber }) {
    const width = Dimensions.get('window').width;
    let pageComponents = [<Comp />, <Comp />, <Comp />, <Comp />]
    }
    return (<Carousel
        width={width}
        height={width * 2}
        autoPlay={false}
        loop={false}
        data={pageComponents}
        defaultIndex={currentPageNumber == 1 ? 0 : 1}
        modeConfig={{ snapDirection: 'right' }}
        renderItem={({ index }) => {
            return pageComponents[index];
        }}
    />)
}


问:
Azure B2C ProfileEdit custom policy + Azure B2c session management
please I am currently trying to use Azure AD b2c custom policy and I have two different questions;

Is it possible to configure B2c Custom policy to have a user option
to reset phone number and/or totp from the user profile. Preferable
like a checkbox to reset the values?.

I am aware that that Azure AD B2C doesn't control the federated
identity provider session. A social or enterprise identity provider
manages its own session i.e, session behavior is determined by the
federated identity provider.
how do I keep my application session to AD B2C alive as long as possible, to avoid redirecting users to the federated identity
provider before it is absolutely necessary.
Please help, thanks.


问:
binding multiple labels and corresponding button created in a function, customtkinter
I've just started using Customtkinter in Python to create UI. I wrote a function to create a button and a label, which can of course be called several times. The label text should be updated when the button is clicked. Example: second label updated when clicking the second button.

Problem is: When the function is called multiple times (eg. 3 times), only the last label (eg. 3rd label) can be updated by clicking any button (eg. 1st-3rd button).

I tried to use the dictionary to bind the button and label, but didn't work. With or without a dictionary, the result is always the same. Down below is the relevant code:

```<code>
import customtkinter as ctk

def __init__(self, master):
    self.toplevel = ctk.CTkToplevel()
    rollnum = 0
    myDict = {}

def update(self, button)
    new_label = myDict[button]

    # str_label gets value from somewhere else, here is only an example
    str_label = "Test label"
    new_label.configure(text=str_label)

def create_row (self)
    # creating label and button, bind them with dictionary
    self.selection_label = ctk.CTkLabel(self.toplevel, text="")
    self.choice_button = ctk.CTkButton(self.toplevel, text="Select",
                                       command=lambda: self.update(self.choice_button))
    myDict[self.choice_button] = self.selection_label

    self.selection_label.grid(column=0, row=rollnum)
    self.choice_button.grid(column=1, row=rollnum)
    rollnum += 1

</code>```

Thanks a lot for helping.

Body:
I've just started using Customtkinter in Python to create UI. I wrote a function to create a button and a label, which can of course be called several times. The label text should be updated when the button is clicked. Example: second label updated when clicking the second button.

Problem is: When the function is called multiple times (eg. 3 times), only the last label (eg. 3rd label) can be updated by clicking any button (eg. 1st-3rd button).

I tried to use the dictionary to bind the button and label, but didn't work. With or without a dictionary, the result is always the same. Down below is the relevant code:

import customtkinter as ctk

def __init__(self, master):
    self.toplevel = ctk.CTkToplevel()
    rollnum = 0
    myDict = {}

def update(self, button)
    new_label = myDict[button]

    # str_label gets value from somewhere else, here is only an example
    str_label = "Test label"
    new_label.configure(text=str_label)

def create_row (self)
    # creating label and button, bind them with dictionary
    self.selection_label = ctk.CTkLabel(self.toplevel, text="")
    self.choice_button = ctk.CTkButton(self.toplevel, text="Select",
                                       command=lambda: self.update(self.choice_button))
    myDict[self.choice_button] = self.selection_label

    self.selection_label.grid(column=0, row=rollnum)
    self.choice_button.grid(column=1, row=rollnum)
    rollnum += 1

Thanks a lot for helping.


问:
Import style and convert it into styled object ExcelJs
I imported xlsx file in reactApp using ExcelJs library , I get styles as OpenXml, here is a snippet

Im unable to convert it into styled object for my react app


问:
Creating types for nested destructuring
I'm attempting to set a type for nested destructured object.

Here is the code in which I'm handling:

```<code>import { useGLTF, useTexture } from "@react-three/drei";
import * as THREE from "three";

interface ModelInterface {
  [name: string]: THREE.Mesh;
}

export default function Room() {
  const {
    nodes: { Room },
  }: { nodes: ModelInterface } = useGLTF("./models/room/room.glb");
  const bakedTexture = useTexture("./models/room/baked.png");
  bakedTexture.flipY = false;

  return (
    <mesh geometry={Room.geometry}>
      <meshBasicMaterial map={bakedTexture} />
    </mesh>
  );
}
</code>```

I will be receiving this response, This is the nodes log.

```<code>{
   Room: Mesh {
      ...data from mesh
   },
   Scene: Group {
      ...data from group
   }
}
</code>```

for some reason the Room.geometry was no getting caught it was saying it was not a property, although it is, this is why I'm creating a type.

This is the type error I get from the destructured Room:

```<code>Type 'GLTF & ObjectMap' is not assignable to type '{ nodes: ModelInterface; }'.
  Types of property 'nodes' are incompatible.
    Type '{ [name: string]: Object3D<Event>; }' is not assignable to type 'ModelInterface'.
      'string' index signatures are incompatible.
        Type 'Object3D<Event>' is missing the following properties from type 'Mesh<BufferGeometry, Material | Material[]>': geometry, material, isMesh, updateMorphTargetsts(2322)
</code>```

One detail is, the destructuring from nodes, in my case the name Room can come with different names, It could be Bed, or other names...

Title: Creating types for nested destructuring

Body:
I'm attempting to set a type for nested destructured object.

Here is the code in which I'm handling:

import { useGLTF, useTexture } from "@react-three/drei";
import * as THREE from "three";

interface ModelInterface {
  [name: string]: THREE.Mesh;
}

export default function Room() {
  const {
    nodes: { Room },
  }: { nodes: ModelInterface } = useGLTF("./models/room/room.glb");
  const bakedTexture = useTexture("./models/room/baked.png");
  bakedTexture.flipY = false;

  return (
    <mesh geometry={Room.geometry}>
      <meshBasicMaterial map={bakedTexture} />
    </mesh>
  );
}

I will be receiving this response, This is the nodes log.

{
   Room: Mesh {
      ...data from mesh
   },
   Scene: Group {
      ...data from group
   }
}

for some reason the Room.geometry was no getting caught it was saying it was not a property, although it is, this is why I'm creating a type.

This is the type error I get from the destructured Room:

Type 'GLTF & ObjectMap' is not assignable to type '{ nodes: ModelInterface; }'.
  Types of property 'nodes' are incompatible.
    Type '{ [name: string]: Object3D<Event>; }' is not assignable to type 'ModelInterface'.
      'string' index signatures are incompatible.
        Type 'Object3D<Event>' is missing the following properties from type 'Mesh<BufferGeometry, Material | Material[]>': geometry, material, isMesh, updateMorphTargetsts(2322)

One detail is, the destructuring from nodes, in my case the name Room can come with different names, It could be Bed, or other names...


问:
Why i'm geeting an empty Array?
Main function

```<code>export async function postData(TVMID) {
const data = await FetchingData(TVMID)

  // regex the year
  const rex = /^[0-9]{4}/g;
  let country;
  let network;

  let geners = await CheckGenderIfExist(data.genres).then(genx => genx)

more code....

}
</code>```

Check if data exist function

```<code>export async function CheckGenderIfExist(genders) {

  let listOfGenders = [];

  if (Array.isArray(genders)) {
    genders.forEach(gen => {
      axios.get(`${process.env.NEXT_PUBLIC_API_URL}/api/genders?filters[$and][0][Name][$eq]=${gen}`)
        .then((response) => {
          if (response.data.data.length == 0) {
            AddTVGenders(gen)
          } else {
            listOfGenders.push(response.data.data[0].id)
          }
        });
    })
  } else {
    axios.get(`${process.env.NEXT_PUBLIC_API_URL}/api/genders?filters[$and][0][Name][$eq]=${genders}`)
      .then((response) => {
        listOfGenders.push(response.data.data[0].id)
      });
  }

  return listOfGstenders;
}
</code>```

Add missing data function

```<code>export async function AddTVGenders(gen) {

  await axios.post(`${process.env.NEXT_PUBLIC_API_URL}/api/genders`, {
    headers: {
      Authorization: `Bearer ${process.env.API_TOKEN}`,
    },
    "data": {
      Name: gen,
    }
  })

  CheckGenderIfExist(gen)

}
</code>```

Im' using strapi v4.5 with nextjs v13, while tring to post data for some of the relation fields , i have to check if the data exist if not, i create it then get the id then add it to the main post function
This is what i came up with but it return empty array

Title: Why i'm geeting an empty Array?

Body:
Main function

export async function postData(TVMID) {
const data = await FetchingData(TVMID)

  // regex the year
  const rex = /^[0-9]{4}/g;
  let country;
  let network;

  let geners = await CheckGenderIfExist(data.genres).then(genx => genx)

more code....

}

Check if data exist function

export async function CheckGenderIfExist(genders) {

  let listOfGenders = [];

  if (Array.isArray(genders)) {
    genders.forEach(gen => {
      axios.get(`${process.env.NEXT_PUBLIC_API_URL}/api/genders?filters[$and][0][Name][$eq]=${gen}`)
        .then((response) => {
          if (response.data.data.length == 0) {
            AddTVGenders(gen)
          } else {
            listOfGenders.push(response.data.data[0].id)
          }
        });
    })
  } else {
    axios.get(`${process.env.NEXT_PUBLIC_API_URL}/api/genders?filters[$and][0][Name][$eq]=${genders}`)
      .then((response) => {
        listOfGenders.push(response.data.data[0].id)
      });
  }

  return listOfGstenders;
}

Add missing data function

export async function AddTVGenders(gen) {

  await axios.post(`${process.env.NEXT_PUBLIC_API_URL}/api/genders`, {
    headers: {
      Authorization: `Bearer ${process.env.API_TOKEN}`,
    },
    "data": {
      Name: gen,
    }
  })

  CheckGenderIfExist(gen)

}

Im' using strapi v4.5 with nextjs v13, while tring to post data for some of the relation fields , i have to check if the data exist if not, i create it then get the id then add it to the main post function
This is what i came up with but it return empty array


问:
plot function can't identiy inner components
i  am trying to implement  codes presented here :
Q learning code

one of the helper  code is presented here :

```<code>import matplotlib
import numpy as np
import pandas as pd
from collections import namedtuple
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

EpisodeStats = namedtuple("Stats",["episode_lengths", "episode_rewards"])

def plot_cost_to_go_mountain_car(env, estimator, num_tiles=20):
    x = np.linspace(env.observation_space.low[0], env.observation_space.high[0], num=num_tiles)
    y = np.linspace(env.observation_space.low[1], env.observation_space.high[1], num=num_tiles)
    X, Y = np.meshgrid(x, y)
    Z = np.apply_along_axis(lambda _: -np.max(estimator.predict(_)), 2, np.dstack([X, Y]))

    fig = plt.figure(figsize=(10, 5))
    ax = fig.add_subplot(111, projection='3d')
    surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1,
                           cmap=matplotlib.cm.coolwarm, vmin=-1.0, vmax=1.0)
    ax.set_xlabel('Position')
    ax.set_ylabel('Velocity')
    ax.set_zlabel('Value')
    ax.set_title("Mountain \"Cost To Go\" Function")
    fig.colorbar(surf)
    plt.show()

def plot_value_function(V, title="Value Function"):
    """
    Plots the value function as a surface plot.
    """
    min_x = min(k[0] for k in V.keys())
    max_x = max(k[0] for k in V.keys())
    min_y = min(k[1] for k in V.keys())
    max_y = max(k[1] for k in V.keys())

    x_range = np.arange(min_x, max_x + 1)
    y_range = np.arange(min_y, max_y + 1)
    X, Y = np.meshgrid(x_range, y_range)

    # Find value for all (x, y) coordinates
    Z_noace = np.apply_along_axis(lambda _: V[(_[0], _[1], False)], 2, np.dstack([X, Y]))
    Z_ace = np.apply_along_axis(lambda _: V[(_[0], _[1], True)], 2, np.dstack([X, Y]))

    def plot_surface(X, Y, Z, title):
        fig = plt.figure(figsize=(20, 10))
        ax = fig.add_subplot(111, projection='3d')
        surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1,
                               cmap=matplotlib.cm.coolwarm, vmin=-1.0, vmax=1.0)
        ax.set_xlabel('Player Sum')
        ax.set_ylabel('Dealer Showing')
        ax.set_zlabel('Value')
        ax.set_title(title)
        ax.view_init(ax.elev, -120)
        fig.colorbar(surf)
        plt.show()

    plot_surface(X, Y, Z_noace, "{} (No Usable Ace)".format(title))
    plot_surface(X, Y, Z_ace, "{} (Usable Ace)".format(title))

def plot_episode_stats(stats, smoothing_window=10, noshow=False):
    # Plot the episode length over time
    fig1 = plt.figure(figsize=(10,5))
    plt.plot(stats.episode_lengths)
    plt.xlabel("Episode")
    plt.ylabel("Episode Length")
    plt.title("Episode Length over Time")
    if noshow:
        plt.close(fig1)
    else:
        plt.show(fig1)

    # Plot the episode reward over time
    fig2 = plt.figure(figsize=(10,5))
    rewards_smoothed = pd.Series(stats.episode_rewards).rolling(smoothing_window, min_periods=smoothing_window).mean()
    plt.plot(rewards_smoothed)
    plt.xlabel("Episode")
    plt.ylabel("Episode Reward (Smoothed)")
    plt.title("Episode Reward over Time (Smoothed over window size {})".format(smoothing_window))
    if noshow:
        plt.close(fig2)
    else:
        plt.show(fig2)

    # Plot time steps and episode number
    fig3 = plt.figure(figsize=(10,5))
    plt.plot(np.cumsum(stats.episode_lengths), np.arange(len(stats.episode_lengths)))
    plt.xlabel("Time Steps")
    plt.ylabel("Episode")
    plt.title("Episode per time step")
    if noshow:
        plt.close(fig3)
    else:
        plt.show(fig3)

    return fig1, fig2, fig3
</code>```

and also :

```<code>import gym
import numpy as np
import sys
from gym.envs.toy_text import discrete

UP = 0
RIGHT = 1
DOWN = 2
LEFT = 3

class WindyGridworldEnv(discrete.DiscreteEnv):

    metadata = {'render.modes': ['human', 'ansi']}

    def _limit_coordinates(self, coord):
        coord[0] = min(coord[0], self.shape[0] - 1)
        coord[0] = max(coord[0], 0)
        coord[1] = min(coord[1], self.shape[1] - 1)
        coord[1] = max(coord[1], 0)
        return coord

    def _calculate_transition_prob(self, current, delta, winds):
        new_position = np.array(current) + np.array(delta) + np.array([-1, 0]) * winds[tuple(current)]
        new_position = self._limit_coordinates(new_position).astype(int)
        new_state = np.ravel_multi_index(tuple(new_position), self.shape)
        is_done = tuple(new_position) == (3, 7)
        return [(1.0, new_state, -1.0, is_done)]

    def __init__(self):
        self.shape = (7, 10)

        nS = np.prod(self.shape)
        nA = 4

        # Wind strength
        winds = np.zeros(self.shape)
        winds[:,[3,4,5,8]] = 1
        winds[:,[6,7]] = 2

        # Calculate transition probabilities
        P = {}
        for s in range(nS):
            position = np.unravel_index(s, self.shape)
            P[s] = { a : [] for a in range(nA) }
            P[s][UP] = self._calculate_transition_prob(position, [-1, 0], winds)
            P[s][RIGHT] = self._calculate_transition_prob(position, [0, 1], winds)
            P[s][DOWN] = self._calculate_transition_prob(position, [1, 0], winds)
            P[s][LEFT] = self._calculate_transition_prob(position, [0, -1], winds)

        # We always start in state (3, 0)
        isd = np.zeros(nS)
        isd[np.ravel_multi_index((3,0), self.shape)] = 1.0

        super(WindyGridworldEnv, self).__init__(nS, nA, P, isd)

    def render(self, mode='human', close=False):
        self._render(mode, close)

    def _render(self, mode='human', close=False):
        if close:
            return

        outfile = StringIO() if mode == 'ansi' else sys.stdout

        for s in range(self.nS):
            position = np.unravel_index(s, self.shape)
            # print(self.s)
            if self.s == s:
                output = " x "
            elif position == (3,7):
                output = " T "
            else:
                output = " o "

            if position[1] == 0:
                output = output.lstrip()
            if position[1] == self.shape[1] - 1:
                output = output.rstrip()
                output += "\n"

            outfile.write(output)
        outfile.write("\n")
</code>```

based on those codes, i have tried to write code :

```<code>import gym
import itertools
import matplotlib
import matplotlib.style
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import os
from collections import defaultdict
from windy_gridworld import WindyGridworldEnv
import plotting
matplotlib.style.use('ggplot')
env =WindyGridworldEnv()
def createEpsilonGreedyPOlicy(Q,epsilon,num_actions):
    def policyFunction(state):
        Action_probabilities =np.ones(num_actions,dtype=float) *epsilon /num_actions
        best_action =np.argmax(Q[state])
        Action_probabilities[best_action]+=(1.0-epsilon)
        return  Action_probabilities
    return policyFunction
def  qLearning(env,num_episodes,discount_factor=1.0,alpha=0.6,epsilon=0.1):
    Q =defaultdict(lambda:np.zeros(env.action_space.n))
    stats =plotting.EpisodeStats(episode_lengths=np.zeros(num_episodes),episode_rewards=np.zeros(num_episodes))
    policy =createEpsilonGreedyPOlicy(Q,epsilon,env.action_space.n)
    for ith_espisode in range(num_episodes):
        state =env.reset()
        for  t in itertools.count():
            action_probabilities =policy(state)
            action = np.random.choice(np.arange(len(action_probabilities)),p=action_probabilities)
            next_state,reward,done,_ =env.step(action)
            stats.episode_rewards[ith_espisode]+=reward
            stats.episode_lengths[ith_espisode]=t
            best_next_action =np.argmax(Q[next_state])
            td_target =reward+discount_factor*Q[next_state][best_next_action]
            td_delta =td_target -Q[state][action]
            Q[state][action] +=alpha*td_delta
            if done:
                break
            state = next_state

    return Q, stats

Q, stats = qLearning(env, 1000)
#print(stats.episode_lengths
plotting.plot_episode_stats(stats,10)
</code>```

when i am running code i got this error :

```<code>Traceback (most recent call last):
  File "C:\Users\User\PycharmProjects\AI_Project\Q_learning_Example.py", line 45, in <module>
    plotting.plot_episode_stats(stats,10)
  File "C:\Users\User\PycharmProjects\AI_Project\plotting.py", line 73, in plot_episode_stats
    plt.show(fig1)
  File "C:\Users\User\PycharmProjects\AI_Project\venv\lib\site-packages\matplotlib\pyplot.py", line 389, in show
    return _get_backend_mod().show(*args, **kwargs)
TypeError: _Backend.show() takes 1 positional argument but 2 were given
</code>```

could you please help me  to fix this error?i am really enthusiastic in  Deep Reinforcement learning and trying to  new stuff, for instance i have  code fragment

```<code>def plot_episode_stats(stats, smoothing_window=10, noshow=False):
    # Plot the episode length over time
    fig1 = plt.figure(figsize=(10,5))
    plt.plot(stats.episode_lengths)
    plt.xlabel("Episode")
    plt.ylabel("Episode Length")
    plt.title("Episode Length over Time")
    if noshow:
        plt.close(fig1)
    else:
        plt.show(fig1)

    # Plot the episode reward over time
    fig2 = plt.figure(figsize=(10,5))
    rewards_smoothed = pd.Series(stats.episode_rewards).rolling(smoothing_window, min_periods=smoothing_window).mean()
    plt.plot(rewards_smoothed)
    plt.xlabel("Episode")
    plt.ylabel("Episode Reward (Smoothed)")
    plt.title("Episode Reward over Time (Smoothed over window size {})".format(smoothing_window))
    if noshow:
        plt.close(fig2)
    else:
        plt.show(fig2)

    # Plot time steps and episode number
    fig3 = plt.figure(figsize=(10,5))
    plt.plot(np.cumsum(stats.episode_lengths), np.arange(len(stats.episode_lengths)))
    plt.xlabel("Time Steps")
    plt.ylabel("Episode")
    plt.title("Episode per time step")
    if noshow:
        plt.close(fig3)
    else:
        plt.show(fig3)

    return fig1, fig2, fig3
</code>```

for instance if we check stats  result :
print(stats)
we can see
Stats(episode_lengths=array([733., 311., 115., 137., 155., 110.,  28.,  32.,  73., 142., 115.,
45.,  67.,  38.,  29.,  62., 163.,  23.,  95.,  26.,  98.,  42.,
42.,  62.,  24.,  42.,  28.,  37., 102.,  44.,  36.,  91.,  42.,
87.,  99.,  30.,  77.,  45.,  26.,  32.,  28.,  44.,  26.,  37.,
33.,  73.,  36.,  48.,  66.,  25.,  22.,  54.,  33.,  41.,  41.,
20.,  27.,  31.,  30.,  21.,  15.,  30.,  19.,  66.,  25.,  36.,
22.,  24.,  21.,  22.,  18.,  30.,  27.,  26.,  36.,  21.,  19.,
37.,  33.,  21.,  22.,  17.,  24.,  37.,  15.,  18.,  22.,  32.,
17.,  30.,  28.,  17.,  30.,  22.,  22.,  21.,  34.,  17.,  17.,
21.,  14.,  32.,  14.,  21.,  41.,  15.,  16.,  14.,  14.,  17.,
19.,  16.,  16.,  16.,  15.,  15.,  19.,  25.,  22.,  14.,  15.,
15.,  34.,  18.,  14.,  18.,  23.,  17.,  15.,  14.,  14.,  19.,
14.,  14.,  14.,  14.,  14.,  15.,  21.,  18.,  16.,  15.,  15.,
16.,  14.,  17.,  14.,  20.,  19.,  14.,  15.,  14.,  17.,  14.,
15.,  21.,  17.,  15.,  17.,  16.,  20.,  16.,  16.,  15.,  14.,
16.,  14.,  14.,  14.,  20.,  16.,  15.,  14.,  15.,  15.,  17.,
18.,  14.,  16.,  15.,  15.,  14.,  15.,  18.,  14.,  14.,  24.,
16.,  15.,  14.,  18.,  16.,  15.,  14.,  15.,  20.,  17.,  14.,
14.,  19.,  16.,  15.,  28.,  14.,  14.,  14.,  16.,  14.,  17.,
14.,  21.,  16.,  16.,  14.,  14.,  14.,  14.,  21.,  16.,  22.,
21.,  17.,  15.,  14.,  15.,  22.,  14.,  15.,  21.,  16.,  16.,
14.,  17.,  16.,  18.,  16.,  17.,  14.,  20.,  17.,  15.,  14.,
19.,  14.,  19.,  17.,  16.,  16.,  23.,  20.,  17.,  16.,  20.,
15.,  15.,  17.,  19.,  15.,  16.,  14.,  14.,  15.,  14.,  17.,
16.,  16.,  14.,  29.,  14.,  14.,  17.,  17.,  14.,  14.,  15.,
15.,  29.,  16.,  16.,  21.,  27.,  18.,  18.,  20.,  14.,  14.,
20.,  15.,  15.,  15.,  23.,  16.,  23.,  14.,  16.,  16.,  14.,
21.,  28.,  17.,  19.,  22.,  16.,  16.,  14.,  14.,  14.,  18.,
19.,  15.,  14.,  15.,  16.,  22.,  20.,  19.,  16.,  14.,  15.,
18.,  14.,  19.,  15.,  14.,  14.,  14.,  16.,  15.,  15.,  14.,
17.,  17.,  15.,  14.,  17.,  14.,  15.,  16.,  14.,  14.,  14.,
15.,  15.,  14.,  18.,  20.,  14.,  18.,  16.,  14.,  17.,  14.,
14.,  23.,  14.,  14.,  14.,  22.,  19.,  14.,  14.,  19.,  15.,
17.,  17.,  14.,  14.,  19.,  24.,  16.,  16.,  14.,  19.,  19.,
14.,  16.,  14.,  15.,  15.,  14.,  15.,  16.,  14.,  14.,  14.,
16.,  15.,  17.,  17.,  14.,  16.,  15.,  15.,  15.,  19.,  15.,
14.,  22.,  17.,  17.,  14.,  16.,  14.,  14.,  19.,  15.,  14.,
18.,  14.,  16.,  16.,  18.,  22.,  19.,  16.,  18.,  16.,  16.,
14.,  16.,  16.,  15.,  19.,  14.,  18.,  19.,  14.,  26.,  14.,
14.,  15.,  14.,  14.,  18.,  15.,  17.,  14.,  14.,  14.,  15.,
14.,  19.,  14.,  21.,  14.,  15.,  14.,  14.,  17.,  14.,  20.,
15.,  14.,  24.,  15.,  16.,  18.,  17.,  19.,  14.,  14.,  16.,
14.,  16.,  15.,  17.,  18.,  17.,  15.,  17.,  15.,  15.,  22.,
18.,  15.,  16.,  15.,  17.,  32.,  14.,  18.,  15.,  15.,  15.,
14.,  27.,  18.,  18.,  15.,  14.,  16.,  14.,  17.,  15.,  17.,
16.,  14.,  16.,  17.,  17.,  15.,  16.,  15.,  15.,  14.,  16.,
14.,  14.,  16.,  17.,  14.,  14.,  17.,  14.,  16.,  20.,  14.,
22.,  18.,  14.,  25.,  15.,  15.,  15.,  14.,  14.,  15.,  14.,
21.,  19.,  21.,  24.,  16.,  15.,  16.,  15.,  19.,  14.,  15.,
14.,  14.,  19.,  17.,  16.,  14.,  15.,  17.,  16.,  19.,  14.,
17.,  21.,  19.,  14.,  14.,  16.,  17.,  15.,  15.,  14.,  16.,
14.,  18.,  22.,  14.,  16.,  14.,  17.,  20.,  14.,  15.,  16.,
14.,  20.,  17.,  19.,  14.,  14.,  14.,  17.,  16.,  14.,  16.,
14.,  16.,  15.,  15.,  20.,  15.,  20.,  16.,  21.,  20.,  16.,
19.,  17.,  14.,  14.,  14.,  16.,  18.,  20.,  16.,  14.,  18.,
15.,  14.,  15.,  22.,  14.,  19.,  14.,  16.,  14.,  16.,  17.,
15.,  20.,  25.,  15.,  14.,  14.,  16.,  15.,  15.,  15.,  14.,
14.,  14.,  16.,  14.,  14.,  14.,  14.,  21.,  14.,  17.,  20.,
19.,  17.,  15.,  16.,  14.,  14.,  15.,  17.,  18.,  17.,  19.,
15.,  14.,  17.,  14.,  15.,  16.,  14.,  18.,  18.,  16.,  17.,
17.,  15.,  14.,  15.,  18.,  14.,  16.,  14.,  17.,  15.,  16.,
14.,  15.,  16.,  17.,  17.,  16.,  15.,  17.,  15.,  15.,  21.,
14.,  14.,  15.,  14.,  15.,  16.,  16.,  15.,  15.,  15.,  14.,
14.,  19.,  15.,  14.,  20.,  17.,  15.,  14.,  16.,  17.,  16.,
17.,  14.,  15.,  14.,  18.,  20.,  15.,  14.,  17.,  18.,  15.,
18.,  14.,  19.,  14.,  15.,  16.,  16.,  16.,  14.,  18.,  18.,
16.,  14.,  14.,  17.,  22.,  15.,  14.,  15.,  17.,  17.,  22.,
14.,  20.,  14.,  16.,  14.,  14.,  14.,  16.,  15.,  18.,  17.,
14.,  14.,  14.,  17.,  19.,  14.,  19.,  16.,  16.,  17.,  18.,
14.,  19.,  15.,  14.,  15.,  14.,  19.,  14.,  20.,  14.,  15.,
14.,  15.,  15.,  15.,  14.,  14.,  14.,  18.,  14.,  14.,  14.,
17.,  15.,  17.,  15.,  16.,  14.,  15.,  14.,  16.,  15.,  15.,
14.,  14.,  14.,  15.,  15.,  17.,  22.,  14.,  15.,  14.,  14.,
14.,  18.,  14.,  17.,  14.,  15.,  20.,  14.,  15.,  15.,  17.,
18.,  16.,  16.,  19.,  14.,  14.,  15.,  14.,  18.,  14.,  22.,
14.,  14.,  14.,  16.,  15.,  15.,  14.,  14.,  17.,  18.,  19.,
16.,  18.,  16.,  16.,  18.,  14.,  16.,  19.,  18.,  16.,  16.,
26.,  18.,  18.,  14.,  18.,  18.,  14.,  15.,  14.,  21.,  15.,
18.,  16.,  18.,  14.,  17.,  15.,  14.,  14.,  15.,  15.,  16.,
14.,  16.,  14.,  16.,  16.,  15.,  19.,  17.,  15.,  16.,  14.,
18.,  15.,  18.,  16.,  18.,  16.,  15.,  14.,  17.,  14.,  19.,
15.,  15.,  16.,  16.,  16.,  14.,  14.,  20.,  18.,  16.,  14.,
15.,  16.,  17.,  15.,  15.,  18.,  14.,  15.,  15.,  15.,  15.,
15.,  16.,  16.,  17.,  14.,  16.,  19.,  14.,  17.,  15.,  14.,
14.,  17.,  14.,  15.,  15.,  14.,  14.,  17.,  15.,  15.,  14.,
17.,  16.,  16.,  17.,  14.,  14.,  14.,  15.,  15.,  14.,  14.,
15.,  16.,  16.,  14.,  16.,  17.,  14.,  23.,  14.,  14.,  18.,
14.,  16.,  15.,  14.,  19.,  15.,  14.,  17.,  16.,  14.,  16.,
19.,  14.,  16.,  18.,  26.,  14.,  22.,  14.,  16.,  14.,  22.,
16.,  15.,  14.,  15.,  14.,  14.,  14.,  14.,  14.,  14.,  17.,
15.,  14.,  14.,  17.,  15.,  17.,  17.,  15.,  14.,  18.]), episode_rewards=array([-734., -312., -116., -138., -156., -111.,  -29.,  -33.,  -74.,
-143., -116.,  -46.,  -68.,  -39.,  -30.,  -63., -164.,  -24.,
-96.,  -27.,  -99.,  -43.,  -43.,  -63.,  -25.,  -43.,  -29.,
-38., -103.,  -45.,  -37.,  -92.,  -43.,  -88., -100.,  -31.,
-78.,  -46.,  -27.,  -33.,  -29.,  -45.,  -27.,  -38.,  -34.,
-74.,  -37.,  -49.,  -67.,  -26.,  -23.,  -55.,  -34.,  -42.,
-42.,  -21.,  -28.,  -32.,  -31.,  -22.,  -16.,  -31.,  -20.,
-67.,  -26.,  -37.,  -23.,  -25.,  -22.,  -23.,  -19.,  -31.,
-28.,  -27.,  -37.,  -22.,  -20.,  -38.,  -34.,  -22.,  -23.,
-18.,  -25.,  -38.,  -16.,  -19.,  -23.,  -33.,  -18.,  -31.,
-29.,  -18.,  -31.,  -23.,  -23.,  -22.,  -35.,  -18.,  -18.,
-22.,  -15.,  -33.,  -15.,  -22.,  -42.,  -16.,  -17.,  -15.,
-15.,  -18.,  -20.,  -17.,  -17.,  -17.,  -16.,  -16.,  -20.,
-26.,  -23.,  -15.,  -16.,  -16.,  -35.,  -19.,  -15.,  -19.,
-24.,  -18.,  -16.,  -15.,  -15.,  -20.,  -15.,  -15.,  -15.,
-15.,  -15.,  -16.,  -22.,  -19.,  -17.,  -16.,  -16.,  -17.,
-15.,  -18.,  -15.,  -21.,  -20.,  -15.,  -16.,  -15.,  -18.,
-15.,  -16.,  -22.,  -18.,  -16.,  -18.,  -17.,  -21.,  -17.,
-17.,  -16.,  -15.,  -17.,  -15.,  -15.,  -15.,  -21.,  -17.,
-16.,  -15.,  -16.,  -16.,  -18.,  -19.,  -15.,  -17.,  -16.,
-16.,  -15.,  -16.,  -19.,  -15.,  -15.,  -25.,  -17.,  -16.,
-15.,  -19.,  -17.,  -16.,  -15.,  -16.,  -21.,  -18.,  -15.,
-15.,  -20.,  -17.,  -16.,  -29.,  -15.,  -15.,  -15.,  -17.,
-15.,  -18.,  -15.,  -22.,  -17.,  -17.,  -15.,  -15.,  -15.,
-15.,  -22.,  -17.,  -23.,  -22.,  -18.,  -16.,  -15.,  -16.,
-23.,  -15.,  -16.,  -22.,  -17.,  -17.,  -15.,  -18.,  -17.,
-19.,  -17.,  -18.,  -15.,  -21.,  -18.,  -16.,  -15.,  -20.,
-15.,  -20.,  -18.,  -17.,  -17.,  -24.,  -21.,  -18.,  -17.,
-21.,  -16.,  -16.,  -18.,  -20.,  -16.,  -17.,  -15.,  -15.,
-16.,  -15.,  -18.,  -17.,  -17.,  -15.,  -30.,  -15.,  -15.,
-18.,  -18.,  -15.,  -15.,  -16.,  -16.,  -30.,  -17.,  -17.,
-22.,  -28.,  -19.,  -19.,  -21.,  -15.,  -15.,  -21.,  -16.,
-16.,  -16.,  -24.,  -17.,  -24.,  -15.,  -17.,  -17.,  -15.,
-22.,  -29.,  -18.,  -20.,  -23.,  -17.,  -17.,  -15.,  -15.,
-15.,  -19.,  -20.,  -16.,  -15.,  -16.,  -17.,  -23.,  -21.,
-20.,  -17.,  -15.,  -16.,  -19.,  -15.,  -20.,  -16.,  -15.,
-15.,  -15.,  -17.,  -16.,  -16.,  -15.,  -18.,  -18.,  -16.,
-15.,  -18.,  -15.,  -16.,  -17.,  -15.,  -15.,  -15.,  -16.,
-16.,  -15.,  -19.,  -21.,  -15.,  -19.,  -17.,  -15.,  -18.,
-15.,  -15.,  -24.,  -15.,  -15.,  -15.,  -23.,  -20.,  -15.,
-15.,  -20.,  -16.,  -18.,  -18.,  -15.,  -15.,  -20.,  -25.,
-17.,  -17.,  -15.,  -20.,  -20.,  -15.,  -17.,  -15.,  -16.,
-16.,  -15.,  -16.,  -17.,  -15.,  -15.,  -15.,  -17.,  -16.,
-18.,  -18.,  -15.,  -17.,  -16.,  -16.,  -16.,  -20.,  -16.,
-15.,  -23.,  -18.,  -18.,  -15.,  -17.,  -15.,  -15.,  -20.,
-16.,  -15.,  -19.,  -15.,  -17.,  -17.,  -19.,  -23.,  -20.,
-17.,  -19.,  -17.,  -17.,  -15.,  -17.,  -17.,  -16.,  -20.,
-15.,  -19.,  -20.,  -15.,  -27.,  -15.,  -15.,  -16.,  -15.,
-15.,  -19.,  -16.,  -18.,  -15.,  -15.,  -15.,  -16.,  -15.,
-20.,  -15.,  -22.,  -15.,  -16.,  -15.,  -15.,  -18.,  -15.,
-21.,  -16.,  -15.,  -25.,  -16.,  -17.,  -19.,  -18.,  -20.,
-15.,  -15.,  -17.,  -15.,  -17.,  -16.,  -18.,  -19.,  -18.,
-16.,  -18.,  -16.,  -16.,  -23.,  -19.,  -16.,  -17.,  -16.,
-18.,  -33.,  -15.,  -19.,  -16.,  -16.,  -16.,  -15.,  -28.,
-19.,  -19.,  -16.,  -15.,  -17.,  -15.,  -18.,  -16.,  -18.,
-17.,  -15.,  -17.,  -18.,  -18.,  -16.,  -17.,  -16.,  -16.,
-15.,  -17.,  -15.,  -15.,  -17.,  -18.,  -15.,  -15.,  -18.,
-15.,  -17.,  -21.,  -15.,  -23.,  -19.,  -15.,  -26.,  -16.,
-16.,  -16.,  -15.,  -15.,  -16.,  -15.,  -22.,  -20.,  -22.,
-25.,  -17.,  -16.,  -17.,  -16.,  -20.,  -15.,  -16.,  -15.,
-15.,  -20.,  -18.,  -17.,  -15.,  -16.,  -18.,  -17.,  -20.,
-15.,  -18.,  -22.,  -20.,  -15.,  -15.,  -17.,  -18.,  -16.,
-16.,  -15.,  -17.,  -15.,  -19.,  -23.,  -15.,  -17.,  -15.,
-18.,  -21.,  -15.,  -16.,  -17.,  -15.,  -21.,  -18.,  -20.,
-15.,  -15.,  -15.,  -18.,  -17.,  -15.,  -17.,  -15.,  -17.,
-16.,  -16.,  -21.,  -16.,  -21.,  -17.,  -22.,  -21.,  -17.,
-20.,  -18.,  -15.,  -15.,  -15.,  -17.,  -19.,  -21.,  -17.,
-15.,  -19.,  -16.,  -15.,  -16.,  -23.,  -15.,  -20.,  -15.,
-17.,  -15.,  -17.,  -18.,  -16.,  -21.,  -26.,  -16.,  -15.,
-15.,  -17.,  -16.,  -16.,  -16.,  -15.,  -15.,  -15.,  -17.,
-15.,  -15.,  -15.,  -15.,  -22.,  -15.,  -18.,  -21.,  -20.,
-18.,  -16.,  -17.,  -15.,  -15.,  -16.,  -18.,  -19.,  -18.,
-20.,  -16.,  -15.,  -18.,  -15.,  -16.,  -17.,  -15.,  -19.,
-19.,  -17.,  -18.,  -18.,  -16.,  -15.,  -16.,  -19.,  -15.,
-17.,  -15.,  -18.,  -16.,  -17.,  -15.,  -16.,  -17.,  -18.,
-18.,  -17.,  -16.,  -18.,  -16.,  -16.,  -22.,  -15.,  -15.,
-16.,  -15.,  -16.,  -17.,  -17.,  -16.,  -16.,  -16.,  -15.,
-15.,  -20.,  -16.,  -15.,  -21.,  -18.,  -16.,  -15.,  -17.,
-18.,  -17.,  -18.,  -15.,  -16.,  -15.,  -19.,  -21.,  -16.,
-15.,  -18.,  -19.,  -16.,  -19.,  -15.,  -20.,  -15.,  -16.,
-17.,  -17.,  -17.,  -15.,  -19.,  -19.,  -17.,  -15.,  -15.,
-18.,  -23.,  -16.,  -15.,  -16.,  -18.,  -18.,  -23.,  -15.,
-21.,  -15.,  -17.,  -15.,  -15.,  -15.,  -17.,  -16.,  -19.,
-18.,  -15.,  -15.,  -15.,  -18.,  -20.,  -15.,  -20.,  -17.,
-17.,  -18.,  -19.,  -15.,  -20.,  -16.,  -15.,  -16.,  -15.,
-20.,  -15.,  -21.,  -15.,  -16.,  -15.,  -16.,  -16.,  -16.,
-15.,  -15.,  -15.,  -19.,  -15.,  -15.,  -15.,  -18.,  -16.,
-18.,  -16.,  -17.,  -15.,  -16.,  -15.,  -17.,  -16.,  -16.,
-15.,  -15.,  -15.,  -16.,  -16.,  -18.,  -23.,  -15.,  -16.,
-15.,  -15.,  -15.,  -19.,  -15.,  -18.,  -15.,  -16.,  -21.,
-15.,  -16.,  -16.,  -18.,  -19.,  -17.,  -17.,  -20.,  -15.,
-15.,  -16.,  -15.,  -19.,  -15.,  -23.,  -15.,  -15.,  -15.,
-17.,  -16.,  -16.,  -15.,  -15.,  -18.,  -19.,  -20.,  -17.,
-19.,  -17.,  -17.,  -19.,  -15.,  -17.,  -20.,  -19.,  -17.,
-17.,  -27.,  -19.,  -19.,  -15.,  -19.,  -19.,  -15.,  -16.,
-15.,  -22.,  -16.,  -19.,  -17.,  -19.,  -15.,  -18.,  -16.,
-15.,  -15.,  -16.,  -16.,  -17.,  -15.,  -17.,  -15.,  -17.,
-17.,  -16.,  -20.,  -18.,  -16.,  -17.,  -15.,  -19.,  -16.,
-19.,  -17.,  -19.,  -17.,  -16.,  -15.,  -18.,  -15.,  -20.,
-16.,  -16.,  -17.,  -17.,  -17.,  -15.,  -15.,  -21.,  -19.,
-17.,  -15.,  -16.,  -17.,  -18.,  -16.,  -16.,  -19.,  -15.,
-16.,  -16.,  -16.,  -16.,  -16.,  -17.,  -17.,  -18.,  -15.,
-17.,  -20.,  -15.,  -18.,  -16.,  -15.,  -15.,  -18.,  -15.,
-16.,  -16.,  -15.,  -15.,  -18.,  -16.,  -16.,  -15.,  -18.,
-17.,  -17.,  -18.,  -15.,  -15.,  -15.,  -16.,  -16.,  -15.,
-15.,  -16.,  -17.,  -17.,  -15.,  -17.,  -18.,  -15.,  -24.,
-15.,  -15.,  -19.,  -15.,  -17.,  -16.,  -15.,  -20.,  -16.,
-15.,  -18.,  -17.,  -15.,  -17.,  -20.,  -15.,  -17.,  -19.,
-27.,  -15.,  -23.,  -15.,  -17.,  -15.,  -23.,  -17.,  -16.,
-15.,  -16.,  -15.,  -15.,  -15.,  -15.,  -15.,  -15.,  -18.,
-16.,  -15.,  -15.,  -18.,  -16.,  -18.,  -18.,  -16.,  -15.,
-19.]))
it contains both  list and is considered in the plot part, so what kind of error is  shown?

Body:
i  am trying to implement  codes presented here :
Q learning code

one of the helper  code is presented here :

import matplotlib
import numpy as np
import pandas as pd
from collections import namedtuple
from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

EpisodeStats = namedtuple("Stats",["episode_lengths", "episode_rewards"])

def plot_cost_to_go_mountain_car(env, estimator, num_tiles=20):
    x = np.linspace(env.observation_space.low[0], env.observation_space.high[0], num=num_tiles)
    y = np.linspace(env.observation_space.low[1], env.observation_space.high[1], num=num_tiles)
    X, Y = np.meshgrid(x, y)
    Z = np.apply_along_axis(lambda _: -np.max(estimator.predict(_)), 2, np.dstack([X, Y]))

    fig = plt.figure(figsize=(10, 5))
    ax = fig.add_subplot(111, projection='3d')
    surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1,
                           cmap=matplotlib.cm.coolwarm, vmin=-1.0, vmax=1.0)
    ax.set_xlabel('Position')
    ax.set_ylabel('Velocity')
    ax.set_zlabel('Value')
    ax.set_title("Mountain \"Cost To Go\" Function")
    fig.colorbar(surf)
    plt.show()

def plot_value_function(V, title="Value Function"):
    """
    Plots the value function as a surface plot.
    """
    min_x = min(k[0] for k in V.keys())
    max_x = max(k[0] for k in V.keys())
    min_y = min(k[1] for k in V.keys())
    max_y = max(k[1] for k in V.keys())

    x_range = np.arange(min_x, max_x + 1)
    y_range = np.arange(min_y, max_y + 1)
    X, Y = np.meshgrid(x_range, y_range)

    # Find value for all (x, y) coordinates
    Z_noace = np.apply_along_axis(lambda _: V[(_[0], _[1], False)], 2, np.dstack([X, Y]))
    Z_ace = np.apply_along_axis(lambda _: V[(_[0], _[1], True)], 2, np.dstack([X, Y]))

    def plot_surface(X, Y, Z, title):
        fig = plt.figure(figsize=(20, 10))
        ax = fig.add_subplot(111, projection='3d')
        surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1,
                               cmap=matplotlib.cm.coolwarm, vmin=-1.0, vmax=1.0)
        ax.set_xlabel('Player Sum')
        ax.set_ylabel('Dealer Showing')
        ax.set_zlabel('Value')
        ax.set_title(title)
        ax.view_init(ax.elev, -120)
        fig.colorbar(surf)
        plt.show()

    plot_surface(X, Y, Z_noace, "{} (No Usable Ace)".format(title))
    plot_surface(X, Y, Z_ace, "{} (Usable Ace)".format(title))

def plot_episode_stats(stats, smoothing_window=10, noshow=False):
    # Plot the episode length over time
    fig1 = plt.figure(figsize=(10,5))
    plt.plot(stats.episode_lengths)
    plt.xlabel("Episode")
    plt.ylabel("Episode Length")
    plt.title("Episode Length over Time")
    if noshow:
        plt.close(fig1)
    else:
        plt.show(fig1)

    # Plot the episode reward over time
    fig2 = plt.figure(figsize=(10,5))
    rewards_smoothed = pd.Series(stats.episode_rewards).rolling(smoothing_window, min_periods=smoothing_window).mean()
    plt.plot(rewards_smoothed)
    plt.xlabel("Episode")
    plt.ylabel("Episode Reward (Smoothed)")
    plt.title("Episode Reward over Time (Smoothed over window size {})".format(smoothing_window))
    if noshow:
        plt.close(fig2)
    else:
        plt.show(fig2)

    # Plot time steps and episode number
    fig3 = plt.figure(figsize=(10,5))
    plt.plot(np.cumsum(stats.episode_lengths), np.arange(len(stats.episode_lengths)))
    plt.xlabel("Time Steps")
    plt.ylabel("Episode")
    plt.title("Episode per time step")
    if noshow:
        plt.close(fig3)
    else:
        plt.show(fig3)

    return fig1, fig2, fig3

and also :

import gym
import numpy as np
import sys
from gym.envs.toy_text import discrete

UP = 0
RIGHT = 1
DOWN = 2
LEFT = 3

class WindyGridworldEnv(discrete.DiscreteEnv):

    metadata = {'render.modes': ['human', 'ansi']}

    def _limit_coordinates(self, coord):
        coord[0] = min(coord[0], self.shape[0] - 1)
        coord[0] = max(coord[0], 0)
        coord[1] = min(coord[1], self.shape[1] - 1)
        coord[1] = max(coord[1], 0)
        return coord

    def _calculate_transition_prob(self, current, delta, winds):
        new_position = np.array(current) + np.array(delta) + np.array([-1, 0]) * winds[tuple(current)]
        new_position = self._limit_coordinates(new_position).astype(int)
        new_state = np.ravel_multi_index(tuple(new_position), self.shape)
        is_done = tuple(new_position) == (3, 7)
        return [(1.0, new_state, -1.0, is_done)]

    def __init__(self):
        self.shape = (7, 10)

        nS = np.prod(self.shape)
        nA = 4

        # Wind strength
        winds = np.zeros(self.shape)
        winds[:,[3,4,5,8]] = 1
        winds[:,[6,7]] = 2

        # Calculate transition probabilities
        P = {}
        for s in range(nS):
            position = np.unravel_index(s, self.shape)
            P[s] = { a : [] for a in range(nA) }
            P[s][UP] = self._calculate_transition_prob(position, [-1, 0], winds)
            P[s][RIGHT] = self._calculate_transition_prob(position, [0, 1], winds)
            P[s][DOWN] = self._calculate_transition_prob(position, [1, 0], winds)
            P[s][LEFT] = self._calculate_transition_prob(position, [0, -1], winds)

        # We always start in state (3, 0)
        isd = np.zeros(nS)
        isd[np.ravel_multi_index((3,0), self.shape)] = 1.0

        super(WindyGridworldEnv, self).__init__(nS, nA, P, isd)

    def render(self, mode='human', close=False):
        self._render(mode, close)

    def _render(self, mode='human', close=False):
        if close:
            return

        outfile = StringIO() if mode == 'ansi' else sys.stdout

        for s in range(self.nS):
            position = np.unravel_index(s, self.shape)
            # print(self.s)
            if self.s == s:
                output = " x "
            elif position == (3,7):
                output = " T "
            else:
                output = " o "

            if position[1] == 0:
                output = output.lstrip()
            if position[1] == self.shape[1] - 1:
                output = output.rstrip()
                output += "\n"

            outfile.write(output)
        outfile.write("\n")

based on those codes, i have tried to write code :

import gym
import itertools
import matplotlib
import matplotlib.style
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import os
from collections import defaultdict
from windy_gridworld import WindyGridworldEnv
import plotting
matplotlib.style.use('ggplot')
env =WindyGridworldEnv()
def createEpsilonGreedyPOlicy(Q,epsilon,num_actions):
    def policyFunction(state):
        Action_probabilities =np.ones(num_actions,dtype=float) *epsilon /num_actions
        best_action =np.argmax(Q[state])
        Action_probabilities[best_action]+=(1.0-epsilon)
        return  Action_probabilities
    return policyFunction
def  qLearning(env,num_episodes,discount_factor=1.0,alpha=0.6,epsilon=0.1):
    Q =defaultdict(lambda:np.zeros(env.action_space.n))
    stats =plotting.EpisodeStats(episode_lengths=np.zeros(num_episodes),episode_rewards=np.zeros(num_episodes))
    policy =createEpsilonGreedyPOlicy(Q,epsilon,env.action_space.n)
    for ith_espisode in range(num_episodes):
        state =env.reset()
        for  t in itertools.count():
            action_probabilities =policy(state)
            action = np.random.choice(np.arange(len(action_probabilities)),p=action_probabilities)
            next_state,reward,done,_ =env.step(action)
            stats.episode_rewards[ith_espisode]+=reward
            stats.episode_lengths[ith_espisode]=t
            best_next_action =np.argmax(Q[next_state])
            td_target =reward+discount_factor*Q[next_state][best_next_action]
            td_delta =td_target -Q[state][action]
            Q[state][action] +=alpha*td_delta
            if done:
                break
            state = next_state

    return Q, stats

Q, stats = qLearning(env, 1000)
#print(stats.episode_lengths
plotting.plot_episode_stats(stats,10)

when i am running code i got this error :

Traceback (most recent call last):
  File "C:\Users\User\PycharmProjects\AI_Project\Q_learning_Example.py", line 45, in <module>
    plotting.plot_episode_stats(stats,10)
  File "C:\Users\User\PycharmProjects\AI_Project\plotting.py", line 73, in plot_episode_stats
    plt.show(fig1)
  File "C:\Users\User\PycharmProjects\AI_Project\venv\lib\site-packages\matplotlib\pyplot.py", line 389, in show
    return _get_backend_mod().show(*args, **kwargs)
TypeError: _Backend.show() takes 1 positional argument but 2 were given

could you please help me  to fix this error?i am really enthusiastic in  Deep Reinforcement learning and trying to  new stuff, for instance i have  code fragment

def plot_episode_stats(stats, smoothing_window=10, noshow=False):
    # Plot the episode length over time
    fig1 = plt.figure(figsize=(10,5))
    plt.plot(stats.episode_lengths)
    plt.xlabel("Episode")
    plt.ylabel("Episode Length")
    plt.title("Episode Length over Time")
    if noshow:
        plt.close(fig1)
    else:
        plt.show(fig1)

    # Plot the episode reward over time
    fig2 = plt.figure(figsize=(10,5))
    rewards_smoothed = pd.Series(stats.episode_rewards).rolling(smoothing_window, min_periods=smoothing_window).mean()
    plt.plot(rewards_smoothed)
    plt.xlabel("Episode")
    plt.ylabel("Episode Reward (Smoothed)")
    plt.title("Episode Reward over Time (Smoothed over window size {})".format(smoothing_window))
    if noshow:
        plt.close(fig2)
    else:
        plt.show(fig2)

    # Plot time steps and episode number
    fig3 = plt.figure(figsize=(10,5))
    plt.plot(np.cumsum(stats.episode_lengths), np.arange(len(stats.episode_lengths)))
    plt.xlabel("Time Steps")
    plt.ylabel("Episode")
    plt.title("Episode per time step")
    if noshow:
        plt.close(fig3)
    else:
        plt.show(fig3)

    return fig1, fig2, fig3

for instance if we check stats  result :
print(stats)
we can see
Stats(episode_lengths=array([733., 311., 115., 137., 155., 110.,  28.,  32.,  73., 142., 115.,
45.,  67.,  38.,  29.,  62., 163.,  23.,  95.,  26.,  98.,  42.,
42.,  62.,  24.,  42.,  28.,  37., 102.,  44.,  36.,  91.,  42.,
87.,  99.,  30.,  77.,  45.,  26.,  32.,  28.,  44.,  26.,  37.,
33.,  73.,  36.,  48.,  66.,  25.,  22.,  54.,  33.,  41.,  41.,
20.,  27.,  31.,  30.,  21.,  15.,  30.,  19.,  66.,  25.,  36.,
22.,  24.,  21.,  22.,  18.,  30.,  27.,  26.,  36.,  21.,  19.,
37.,  33.,  21.,  22.,  17.,  24.,  37.,  15.,  18.,  22.,  32.,
17.,  30.,  28.,  17.,  30.,  22.,  22.,  21.,  34.,  17.,  17.,
21.,  14.,  32.,  14.,  21.,  41.,  15.,  16.,  14.,  14.,  17.,
19.,  16.,  16.,  16.,  15.,  15.,  19.,  25.,  22.,  14.,  15.,
15.,  34.,  18.,  14.,  18.,  23.,  17.,  15.,  14.,  14.,  19.,
14.,  14.,  14.,  14.,  14.,  15.,  21.,  18.,  16.,  15.,  15.,
16.,  14.,  17.,  14.,  20.,  19.,  14.,  15.,  14.,  17.,  14.,
15.,  21.,  17.,  15.,  17.,  16.,  20.,  16.,  16.,  15.,  14.,
16.,  14.,  14.,  14.,  20.,  16.,  15.,  14.,  15.,  15.,  17.,
18.,  14.,  16.,  15.,  15.,  14.,  15.,  18.,  14.,  14.,  24.,
16.,  15.,  14.,  18.,  16.,  15.,  14.,  15.,  20.,  17.,  14.,
14.,  19.,  16.,  15.,  28.,  14.,  14.,  14.,  16.,  14.,  17.,
14.,  21.,  16.,  16.,  14.,  14.,  14.,  14.,  21.,  16.,  22.,
21.,  17.,  15.,  14.,  15.,  22.,  14.,  15.,  21.,  16.,  16.,
14.,  17.,  16.,  18.,  16.,  17.,  14.,  20.,  17.,  15.,  14.,
19.,  14.,  19.,  17.,  16.,  16.,  23.,  20.,  17.,  16.,  20.,
15.,  15.,  17.,  19.,  15.,  16.,  14.,  14.,  15.,  14.,  17.,
16.,  16.,  14.,  29.,  14.,  14.,  17.,  17.,  14.,  14.,  15.,
15.,  29.,  16.,  16.,  21.,  27.,  18.,  18.,  20.,  14.,  14.,
20.,  15.,  15.,  15.,  23.,  16.,  23.,  14.,  16.,  16.,  14.,
21.,  28.,  17.,  19.,  22.,  16.,  16.,  14.,  14.,  14.,  18.,
19.,  15.,  14.,  15.,  16.,  22.,  20.,  19.,  16.,  14.,  15.,
18.,  14.,  19.,  15.,  14.,  14.,  14.,  16.,  15.,  15.,  14.,
17.,  17.,  15.,  14.,  17.,  14.,  15.,  16.,  14.,  14.,  14.,
15.,  15.,  14.,  18.,  20.,  14.,  18.,  16.,  14.,  17.,  14.,
14.,  23.,  14.,  14.,  14.,  22.,  19.,  14.,  14.,  19.,  15.,
17.,  17.,  14.,  14.,  19.,  24.,  16.,  16.,  14.,  19.,  19.,
14.,  16.,  14.,  15.,  15.,  14.,  15.,  16.,  14.,  14.,  14.,
16.,  15.,  17.,  17.,  14.,  16.,  15.,  15.,  15.,  19.,  15.,
14.,  22.,  17.,  17.,  14.,  16.,  14.,  14.,  19.,  15.,  14.,
18.,  14.,  16.,  16.,  18.,  22.,  19.,  16.,  18.,  16.,  16.,
14.,  16.,  16.,  15.,  19.,  14.,  18.,  19.,  14.,  26.,  14.,
14.,  15.,  14.,  14.,  18.,  15.,  17.,  14.,  14.,  14.,  15.,
14.,  19.,  14.,  21.,  14.,  15.,  14.,  14.,  17.,  14.,  20.,
15.,  14.,  24.,  15.,  16.,  18.,  17.,  19.,  14.,  14.,  16.,
14.,  16.,  15.,  17.,  18.,  17.,  15.,  17.,  15.,  15.,  22.,
18.,  15.,  16.,  15.,  17.,  32.,  14.,  18.,  15.,  15.,  15.,
14.,  27.,  18.,  18.,  15.,  14.,  16.,  14.,  17.,  15.,  17.,
16.,  14.,  16.,  17.,  17.,  15.,  16.,  15.,  15.,  14.,  16.,
14.,  14.,  16.,  17.,  14.,  14.,  17.,  14.,  16.,  20.,  14.,
22.,  18.,  14.,  25.,  15.,  15.,  15.,  14.,  14.,  15.,  14.,
21.,  19.,  21.,  24.,  16.,  15.,  16.,  15.,  19.,  14.,  15.,
14.,  14.,  19.,  17.,  16.,  14.,  15.,  17.,  16.,  19.,  14.,
17.,  21.,  19.,  14.,  14.,  16.,  17.,  15.,  15.,  14.,  16.,
14.,  18.,  22.,  14.,  16.,  14.,  17.,  20.,  14.,  15.,  16.,
14.,  20.,  17.,  19.,  14.,  14.,  14.,  17.,  16.,  14.,  16.,
14.,  16.,  15.,  15.,  20.,  15.,  20.,  16.,  21.,  20.,  16.,
19.,  17.,  14.,  14.,  14.,  16.,  18.,  20.,  16.,  14.,  18.,
15.,  14.,  15.,  22.,  14.,  19.,  14.,  16.,  14.,  16.,  17.,
15.,  20.,  25.,  15.,  14.,  14.,  16.,  15.,  15.,  15.,  14.,
14.,  14.,  16.,  14.,  14.,  14.,  14.,  21.,  14.,  17.,  20.,
19.,  17.,  15.,  16.,  14.,  14.,  15.,  17.,  18.,  17.,  19.,
15.,  14.,  17.,  14.,  15.,  16.,  14.,  18.,  18.,  16.,  17.,
17.,  15.,  14.,  15.,  18.,  14.,  16.,  14.,  17.,  15.,  16.,
14.,  15.,  16.,  17.,  17.,  16.,  15.,  17.,  15.,  15.,  21.,
14.,  14.,  15.,  14.,  15.,  16.,  16.,  15.,  15.,  15.,  14.,
14.,  19.,  15.,  14.,  20.,  17.,  15.,  14.,  16.,  17.,  16.,
17.,  14.,  15.,  14.,  18.,  20.,  15.,  14.,  17.,  18.,  15.,
18.,  14.,  19.,  14.,  15.,  16.,  16.,  16.,  14.,  18.,  18.,
16.,  14.,  14.,  17.,  22.,  15.,  14.,  15.,  17.,  17.,  22.,
14.,  20.,  14.,  16.,  14.,  14.,  14.,  16.,  15.,  18.,  17.,
14.,  14.,  14.,  17.,  19.,  14.,  19.,  16.,  16.,  17.,  18.,
14.,  19.,  15.,  14.,  15.,  14.,  19.,  14.,  20.,  14.,  15.,
14.,  15.,  15.,  15.,  14.,  14.,  14.,  18.,  14.,  14.,  14.,
17.,  15.,  17.,  15.,  16.,  14.,  15.,  14.,  16.,  15.,  15.,
14.,  14.,  14.,  15.,  15.,  17.,  22.,  14.,  15.,  14.,  14.,
14.,  18.,  14.,  17.,  14.,  15.,  20.,  14.,  15.,  15.,  17.,
18.,  16.,  16.,  19.,  14.,  14.,  15.,  14.,  18.,  14.,  22.,
14.,  14.,  14.,  16.,  15.,  15.,  14.,  14.,  17.,  18.,  19.,
16.,  18.,  16.,  16.,  18.,  14.,  16.,  19.,  18.,  16.,  16.,
26.,  18.,  18.,  14.,  18.,  18.,  14.,  15.,  14.,  21.,  15.,
18.,  16.,  18.,  14.,  17.,  15.,  14.,  14.,  15.,  15.,  16.,
14.,  16.,  14.,  16.,  16.,  15.,  19.,  17.,  15.,  16.,  14.,
18.,  15.,  18.,  16.,  18.,  16.,  15.,  14.,  17.,  14.,  19.,
15.,  15.,  16.,  16.,  16.,  14.,  14.,  20.,  18.,  16.,  14.,
15.,  16.,  17.,  15.,  15.,  18.,  14.,  15.,  15.,  15.,  15.,
15.,  16.,  16.,  17.,  14.,  16.,  19.,  14.,  17.,  15.,  14.,
14.,  17.,  14.,  15.,  15.,  14.,  14.,  17.,  15.,  15.,  14.,
17.,  16.,  16.,  17.,  14.,  14.,  14.,  15.,  15.,  14.,  14.,
15.,  16.,  16.,  14.,  16.,  17.,  14.,  23.,  14.,  14.,  18.,
14.,  16.,  15.,  14.,  19.,  15.,  14.,  17.,  16.,  14.,  16.,
19.,  14.,  16.,  18.,  26.,  14.,  22.,  14.,  16.,  14.,  22.,
16.,  15.,  14.,  15.,  14.,  14.,  14.,  14.,  14.,  14.,  17.,
15.,  14.,  14.,  17.,  15.,  17.,  17.,  15.,  14.,  18.]), episode_rewards=array([-734., -312., -116., -138., -156., -111.,  -29.,  -33.,  -74.,
-143., -116.,  -46.,  -68.,  -39.,  -30.,  -63., -164.,  -24.,
-96.,  -27.,  -99.,  -43.,  -43.,  -63.,  -25.,  -43.,  -29.,
-38., -103.,  -45.,  -37.,  -92.,  -43.,  -88., -100.,  -31.,
-78.,  -46.,  -27.,  -33.,  -29.,  -45.,  -27.,  -38.,  -34.,
-74.,  -37.,  -49.,  -67.,  -26.,  -23.,  -55.,  -34.,  -42.,
-42.,  -21.,  -28.,  -32.,  -31.,  -22.,  -16.,  -31.,  -20.,
-67.,  -26.,  -37.,  -23.,  -25.,  -22.,  -23.,  -19.,  -31.,
-28.,  -27.,  -37.,  -22.,  -20.,  -38.,  -34.,  -22.,  -23.,
-18.,  -25.,  -38.,  -16.,  -19.,  -23.,  -33.,  -18.,  -31.,
-29.,  -18.,  -31.,  -23.,  -23.,  -22.,  -35.,  -18.,  -18.,
-22.,  -15.,  -33.,  -15.,  -22.,  -42.,  -16.,  -17.,  -15.,
-15.,  -18.,  -20.,  -17.,  -17.,  -17.,  -16.,  -16.,  -20.,
-26.,  -23.,  -15.,  -16.,  -16.,  -35.,  -19.,  -15.,  -19.,
-24.,  -18.,  -16.,  -15.,  -15.,  -20.,  -15.,  -15.,  -15.,
-15.,  -15.,  -16.,  -22.,  -19.,  -17.,  -16.,  -16.,  -17.,
-15.,  -18.,  -15.,  -21.,  -20.,  -15.,  -16.,  -15.,  -18.,
-15.,  -16.,  -22.,  -18.,  -16.,  -18.,  -17.,  -21.,  -17.,
-17.,  -16.,  -15.,  -17.,  -15.,  -15.,  -15.,  -21.,  -17.,
-16.,  -15.,  -16.,  -16.,  -18.,  -19.,  -15.,  -17.,  -16.,
-16.,  -15.,  -16.,  -19.,  -15.,  -15.,  -25.,  -17.,  -16.,
-15.,  -19.,  -17.,  -16.,  -15.,  -16.,  -21.,  -18.,  -15.,
-15.,  -20.,  -17.,  -16.,  -29.,  -15.,  -15.,  -15.,  -17.,
-15.,  -18.,  -15.,  -22.,  -17.,  -17.,  -15.,  -15.,  -15.,
-15.,  -22.,  -17.,  -23.,  -22.,  -18.,  -16.,  -15.,  -16.,
-23.,  -15.,  -16.,  -22.,  -17.,  -17.,  -15.,  -18.,  -17.,
-19.,  -17.,  -18.,  -15.,  -21.,  -18.,  -16.,  -15.,  -20.,
-15.,  -20.,  -18.,  -17.,  -17.,  -24.,  -21.,  -18.,  -17.,
-21.,  -16.,  -16.,  -18.,  -20.,  -16.,  -17.,  -15.,  -15.,
-16.,  -15.,  -18.,  -17.,  -17.,  -15.,  -30.,  -15.,  -15.,
-18.,  -18.,  -15.,  -15.,  -16.,  -16.,  -30.,  -17.,  -17.,
-22.,  -28.,  -19.,  -19.,  -21.,  -15.,  -15.,  -21.,  -16.,
-16.,  -16.,  -24.,  -17.,  -24.,  -15.,  -17.,  -17.,  -15.,
-22.,  -29.,  -18.,  -20.,  -23.,  -17.,  -17.,  -15.,  -15.,
-15.,  -19.,  -20.,  -16.,  -15.,  -16.,  -17.,  -23.,  -21.,
-20.,  -17.,  -15.,  -16.,  -19.,  -15.,  -20.,  -16.,  -15.,
-15.,  -15.,  -17.,  -16.,  -16.,  -15.,  -18.,  -18.,  -16.,
-15.,  -18.,  -15.,  -16.,  -17.,  -15.,  -15.,  -15.,  -16.,
-16.,  -15.,  -19.,  -21.,  -15.,  -19.,  -17.,  -15.,  -18.,
-15.,  -15.,  -24.,  -15.,  -15.,  -15.,  -23.,  -20.,  -15.,
-15.,  -20.,  -16.,  -18.,  -18.,  -15.,  -15.,  -20.,  -25.,
-17.,  -17.,  -15.,  -20.,  -20.,  -15.,  -17.,  -15.,  -16.,
-16.,  -15.,  -16.,  -17.,  -15.,  -15.,  -15.,  -17.,  -16.,
-18.,  -18.,  -15.,  -17.,  -16.,  -16.,  -16.,  -20.,  -16.,
-15.,  -23.,  -18.,  -18.,  -15.,  -17.,  -15.,  -15.,  -20.,
-16.,  -15.,  -19.,  -15.,  -17.,  -17.,  -19.,  -23.,  -20.,
-17.,  -19.,  -17.,  -17.,  -15.,  -17.,  -17.,  -16.,  -20.,
-15.,  -19.,  -20.,  -15.,  -27.,  -15.,  -15.,  -16.,  -15.,
-15.,  -19.,  -16.,  -18.,  -15.,  -15.,  -15.,  -16.,  -15.,
-20.,  -15.,  -22.,  -15.,  -16.,  -15.,  -15.,  -18.,  -15.,
-21.,  -16.,  -15.,  -25.,  -16.,  -17.,  -19.,  -18.,  -20.,
-15.,  -15.,  -17.,  -15.,  -17.,  -16.,  -18.,  -19.,  -18.,
-16.,  -18.,  -16.,  -16.,  -23.,  -19.,  -16.,  -17.,  -16.,
-18.,  -33.,  -15.,  -19.,  -16.,  -16.,  -16.,  -15.,  -28.,
-19.,  -19.,  -16.,  -15.,  -17.,  -15.,  -18.,  -16.,  -18.,
-17.,  -15.,  -17.,  -18.,  -18.,  -16.,  -17.,  -16.,  -16.,
-15.,  -17.,  -15.,  -15.,  -17.,  -18.,  -15.,  -15.,  -18.,
-15.,  -17.,  -21.,  -15.,  -23.,  -19.,  -15.,  -26.,  -16.,
-16.,  -16.,  -15.,  -15.,  -16.,  -15.,  -22.,  -20.,  -22.,
-25.,  -17.,  -16.,  -17.,  -16.,  -20.,  -15.,  -16.,  -15.,
-15.,  -20.,  -18.,  -17.,  -15.,  -16.,  -18.,  -17.,  -20.,
-15.,  -18.,  -22.,  -20.,  -15.,  -15.,  -17.,  -18.,  -16.,
-16.,  -15.,  -17.,  -15.,  -19.,  -23.,  -15.,  -17.,  -15.,
-18.,  -21.,  -15.,  -16.,  -17.,  -15.,  -21.,  -18.,  -20.,
-15.,  -15.,  -15.,  -18.,  -17.,  -15.,  -17.,  -15.,  -17.,
-16.,  -16.,  -21.,  -16.,  -21.,  -17.,  -22.,  -21.,  -17.,
-20.,  -18.,  -15.,  -15.,  -15.,  -17.,  -19.,  -21.,  -17.,
-15.,  -19.,  -16.,  -15.,  -16.,  -23.,  -15.,  -20.,  -15.,
-17.,  -15.,  -17.,  -18.,  -16.,  -21.,  -26.,  -16.,  -15.,
-15.,  -17.,  -16.,  -16.,  -16.,  -15.,  -15.,  -15.,  -17.,
-15.,  -15.,  -15.,  -15.,  -22.,  -15.,  -18.,  -21.,  -20.,
-18.,  -16.,  -17.,  -15.,  -15.,  -16.,  -18.,  -19.,  -18.,
-20.,  -16.,  -15.,  -18.,  -15.,  -16.,  -17.,  -15.,  -19.,
-19.,  -17.,  -18.,  -18.,  -16.,  -15.,  -16.,  -19.,  -15.,
-17.,  -15.,  -18.,  -16.,  -17.,  -15.,  -16.,  -17.,  -18.,
-18.,  -17.,  -16.,  -18.,  -16.,  -16.,  -22.,  -15.,  -15.,
-16.,  -15.,  -16.,  -17.,  -17.,  -16.,  -16.,  -16.,  -15.,
-15.,  -20.,  -16.,  -15.,  -21.,  -18.,  -16.,  -15.,  -17.,
-18.,  -17.,  -18.,  -15.,  -16.,  -15.,  -19.,  -21.,  -16.,
-15.,  -18.,  -19.,  -16.,  -19.,  -15.,  -20.,  -15.,  -16.,
-17.,  -17.,  -17.,  -15.,  -19.,  -19.,  -17.,  -15.,  -15.,
-18.,  -23.,  -16.,  -15.,  -16.,  -18.,  -18.,  -23.,  -15.,
-21.,  -15.,  -17.,  -15.,  -15.,  -15.,  -17.,  -16.,  -19.,
-18.,  -15.,  -15.,  -15.,  -18.,  -20.,  -15.,  -20.,  -17.,
-17.,  -18.,  -19.,  -15.,  -20.,  -16.,  -15.,  -16.,  -15.,
-20.,  -15.,  -21.,  -15.,  -16.,  -15.,  -16.,  -16.,  -16.,
-15.,  -15.,  -15.,  -19.,  -15.,  -15.,  -15.,  -18.,  -16.,
-18.,  -16.,  -17.,  -15.,  -16.,  -15.,  -17.,  -16.,  -16.,
-15.,  -15.,  -15.,  -16.,  -16.,  -18.,  -23.,  -15.,  -16.,
-15.,  -15.,  -15.,  -19.,  -15.,  -18.,  -15.,  -16.,  -21.,
-15.,  -16.,  -16.,  -18.,  -19.,  -17.,  -17.,  -20.,  -15.,
-15.,  -16.,  -15.,  -19.,  -15.,  -23.,  -15.,  -15.,  -15.,
-17.,  -16.,  -16.,  -15.,  -15.,  -18.,  -19.,  -20.,  -17.,
-19.,  -17.,  -17.,  -19.,  -15.,  -17.,  -20.,  -19.,  -17.,
-17.,  -27.,  -19.,  -19.,  -15.,  -19.,  -19.,  -15.,  -16.,
-15.,  -22.,  -16.,  -19.,  -17.,  -19.,  -15.,  -18.,  -16.,
-15.,  -15.,  -16.,  -16.,  -17.,  -15.,  -17.,  -15.,  -17.,
-17.,  -16.,  -20.,  -18.,  -16.,  -17.,  -15.,  -19.,  -16.,
-19.,  -17.,  -19.,  -17.,  -16.,  -15.,  -18.,  -15.,  -20.,
-16.,  -16.,  -17.,  -17.,  -17.,  -15.,  -15.,  -21.,  -19.,
-17.,  -15.,  -16.,  -17.,  -18.,  -16.,  -16.,  -19.,  -15.,
-16.,  -16.,  -16.,  -16.,  -16.,  -17.,  -17.,  -18.,  -15.,
-17.,  -20.,  -15.,  -18.,  -16.,  -15.,  -15.,  -18.,  -15.,
-16.,  -16.,  -15.,  -15.,  -18.,  -16.,  -16.,  -15.,  -18.,
-17.,  -17.,  -18.,  -15.,  -15.,  -15.,  -16.,  -16.,  -15.,
-15.,  -16.,  -17.,  -17.,  -15.,  -17.,  -18.,  -15.,  -24.,
-15.,  -15.,  -19.,  -15.,  -17.,  -16.,  -15.,  -20.,  -16.,
-15.,  -18.,  -17.,  -15.,  -17.,  -20.,  -15.,  -17.,  -19.,
-27.,  -15.,  -23.,  -15.,  -17.,  -15.,  -23.,  -17.,  -16.,
-15.,  -16.,  -15.,  -15.,  -15.,  -15.,  -15.,  -15.,  -18.,
-16.,  -15.,  -15.,  -18.,  -16.,  -18.,  -18.,  -16.,  -15.,
-19.]))
it contains both  list and is considered in the plot part, so what kind of error is  shown?


问:
How access the freight__c object from the Order in the OrderItem trigger in Salesforce?
I'm new to Salesforce development and I'm having trouble executing this trigger module challenge for the course I'm taking.

The challenge consists in making a trigger in the OrderItem that after Inserting or Update of some product fills the Freight__c field of the Order object automatically, and this is where my difficulty lies.

I am accessing the Order Object within the OrderItem Trigger from a Set orderId, and within the orderMap MAP I have access to the Account Object and Freight__c, I have to access the Account object, because the Freight must be chosen from the Account location.

```<code>
 public static List<Order> calculeFreight(List<OrderItem> orderItemList){
        Set <Id> orderIdSet = new Set <Id> ();

        for(OrderItem orderItem : orderItemList){
            orderIdSet.add(orderItem.OrderId);
            }

            Map<Id, Order> orderMap = new Map<Id, Order>([
                SELECT Id, AccountId, Account.CEP__c, Account.City__c,
                Freight__c, Freight__r.CEP__c,Freight__r.City__c, DistributionCenter__c, Freight__r.DistributionCenter__c
                FROM Order
                WHERE Id IN: orderIdSet
            ]);

            System.debug('orderMap=>'+ orderMap); // debug orderMap don't return Freight

</code>```

this code snippet is part of the calculeFreight method, the main method, there is also the searchFreight method, which compares the location of Account and Freight, but the problem is still in the orderMap.

After executing the Trigger, the freight field is still empty, I did a debug test to see what the result of the orderMap was, but it didn't return any freight because the freight is empty in the Order

Note: The field Freight of the Order is of type Lookup

Body:
I'm new to Salesforce development and I'm having trouble executing this trigger module challenge for the course I'm taking.

The challenge consists in making a trigger in the OrderItem that after Inserting or Update of some product fills the Freight__c field of the Order object automatically, and this is where my difficulty lies.

I am accessing the Order Object within the OrderItem Trigger from a Set orderId, and within the orderMap MAP I have access to the Account Object and Freight__c, I have to access the Account object, because the Freight must be chosen from the Account location.

 public static List<Order> calculeFreight(List<OrderItem> orderItemList){
        Set <Id> orderIdSet = new Set <Id> ();

        for(OrderItem orderItem : orderItemList){
            orderIdSet.add(orderItem.OrderId);
            }

            Map<Id, Order> orderMap = new Map<Id, Order>([
                SELECT Id, AccountId, Account.CEP__c, Account.City__c,
                Freight__c, Freight__r.CEP__c,Freight__r.City__c, DistributionCenter__c, Freight__r.DistributionCenter__c
                FROM Order
                WHERE Id IN: orderIdSet
            ]);

            System.debug('orderMap=>'+ orderMap); // debug orderMap don't return Freight

this code snippet is part of the calculeFreight method, the main method, there is also the searchFreight method, which compares the location of Account and Freight, but the problem is still in the orderMap.

After executing the Trigger, the freight field is still empty, I did a debug test to see what the result of the orderMap was, but it didn't return any freight because the freight is empty in the Order

Note: The field Freight of the Order is of type Lookup


问:
Google Tag Manager: _event equals gtm.js condition not satisfied/evaluated after login event in Next.JS application
Good day guys!

I need some help regarding the following: I use the following snippet to initialise the Google Tag Manager in my Next.JS application.

_app.js

```<code><Script id={"data-layer-initialization"} strategy={"afterInteractive"}>
         {`window.dataLayer = window.dataLayer || []`}
</Script>
<Script id="google-tag-manager" strategy="afterInteractive">
                {`(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','${GMT_XXXXX}');`}
</Script>
</code>```

_document.js

```<code><noscript
            dangerouslySetInnerHTML={{
              __html: `<iframe src="https://www.googletagmanager.com/ns.html?id=${GMT_ID2}"
height="0" width="0" style="display:none;visibility:hidden"></iframe>`,
            }}
          />
</code>```

I need to push some data layer information regarding the user details (e.g. id) when he has logged in and for this reason i am using the react-gtm-module. I am initialising basically the tag manager using the related gtmId, passing into the dataLayer object the info needed.

```<code>  useEffect(() => {
    TagManager.initialize({
      gtmId: GMT_ID2,
      dataLayer: {
        event: "login",
        authenticationMethod: 'email',
        userId: userId,
      },
    });
  }, [userId]);
};
</code>```

From the GTM side, I have turned the information (user ID) into a GTM variable (data layer variable) and then insert the user ID variable in the GA4 configuration tag. When testing into the GTM preview mode, I sign-in but the container loaded after the login event does NOT fire the GA4 configuration tag (not evaluating any tags at all).

What am i missing?

I was expecting the GA4 configuration tag to be fired by the container loaded but nothing happened. In fact, no tags were evaluated at all.

Body:
Good day guys!

I need some help regarding the following: I use the following snippet to initialise the Google Tag Manager in my Next.JS application.

_app.js

_document.js

<noscript
            dangerouslySetInnerHTML={{
              __html: ``,
            }}
          />

I need to push some data layer information regarding the user details (e.g. id) when he has logged in and for this reason i am using the react-gtm-module. I am initialising basically the tag manager using the related gtmId, passing into the dataLayer object the info needed.

  useEffect(() => {
    TagManager.initialize({
      gtmId: GMT_ID2,
      dataLayer: {
        event: "login",
        authenticationMethod: 'email',
        userId: userId,
      },
    });
  }, [userId]);
};

From the GTM side, I have turned the information (user ID) into a GTM variable (data layer variable) and then insert the user ID variable in the GA4 configuration tag. When testing into the GTM preview mode, I sign-in but the container loaded after the login event does NOT fire the GA4 configuration tag (not evaluating any tags at all).

What am i missing?

I was expecting the GA4 configuration tag to be fired by the container loaded but nothing happened. In fact, no tags were evaluated at all.


问:
How to add a concatenated hyperlink in Pandas ( multiple values from other columns )
I am trying to automate some manual processes that I have been doing in Gsheet.
Below is the hyperlink that I created in Gsheet. ( so each row will have a **unique **hyperlink )

```<code>=hyperlink(CONCATENATE("https://certform1-0.typeform.com/to/q0OONB7K#date=",K2,"&name=",D2, "&id=",L2,CONCAT(B2," Typeform"))
</code>```

Basically, I want to mimic this in pandas.

Many thanks in advance :)

```<code>def make_hyperlink(value):
    url = "{}"
    return '=HYPERLINK("%s", "%s")' % (url.format(value).split(' ')[0], url.format(value).split(' ')[1])
</code>```

I have seen this solution from other stackoverflow posts, but I'm not sure how to build up on this solution.

Body:
I am trying to automate some manual processes that I have been doing in Gsheet.
Below is the hyperlink that I created in Gsheet. ( so each row will have a **unique **hyperlink )

=hyperlink(CONCATENATE("https://certform1-0.typeform.com/to/q0OONB7K#date=",K2,"&name=",D2, "&id=",L2,CONCAT(B2," Typeform"))

Basically, I want to mimic this in pandas.

Many thanks in advance :)

def make_hyperlink(value):
    url = "{}"
    return '=HYPERLINK("%s", "%s")' % (url.format(value).split(' ')[0], url.format(value).split(' ')[1])

I have seen this solution from other stackoverflow posts, but I'm not sure how to build up on this solution.


问:
image disappears when adding an AddEventListener (DOM)
I'm trying to make a JS puzzle game (image drag and drop). I'm trying to assign the tiles (images) of the puzzle to the event listeners, but then the populate function doesn't work and won't populate the board. When removed it prints the images with no problem. I guess a workaround would be to make an assignEvents() function after the board has been populated. Every help would be much appreciated.

```<code>class PuzzleGame extends Game {
  constructor() {
    super();
    this.rows = 3;
    this.columns = 3;
    //current clicked image, other the one we swap with
    this.currTile;
    this.otherTile;
    this.turns = 0;
    this.imageOrder = [1, 2, 3, 4, 5, 6, 7, 8, 9];
    this.randomOrder = [];
  }
  populateBoard() {
    for (let r = 0; r < this.rows; r++) {
      for (let c = 0; c < this.columns; c++) {
        let tile = document.createElement("img");
        tile.id = r.toString() + "-" + c.toString();
        tile.src = "./images/" + this.randomOrder.shift() + ".png";
        // drag functions
        tile.addEventListener("dragstart", dragStart);
        tile.addEventListener("dragover", dragOver);
        tile.addEventListener("dragenter", dragEnter);
        tile.addEventListener("dragleave", dragLeave);
        tile.addEventListener("drop", dragDrop);
        tile.addEventListener("dragend", dragEnd);

        document.getElementById("board").append(tile);
      }
    }
  }
  _randomizeOrder() {
    if (!this.imageOrder) return undefined;
    this.randomOrder = this.imageOrder.sort(function () {
      return Math.random() - 0.5;
    });
    return this.randomOrder;
  }
  puzzleStart() {
    this._randomizeOrder();
    this.populateBoard();
  }
  dragStart() {
    this.currTile = this; //image being dragged
  }
  dragOver(e) {
    e.preventDefault();
  }
  dragEnter(e) {
    e.preventDefault();
  }
  dragLeave() {}
  dragDrop() {
    this.otherTile = this; //image tile being dropped on
  }
  dragEnd() {
    let currImg = this.currTile.src;
    let otherImg = this.otherTile.src;
    this.currTile.src = otherImg;
    this.otherTile.src = currImg;
  }
}
</code>```

I tried to assign the addeventlisteners to the tiles of the game while populating the board. In each iteration of the loop I tried to assign the events expecting to populate it AND at the same time painting the image on the board.

Body:
I'm trying to make a JS puzzle game (image drag and drop). I'm trying to assign the tiles (images) of the puzzle to the event listeners, but then the populate function doesn't work and won't populate the board. When removed it prints the images with no problem. I guess a workaround would be to make an assignEvents() function after the board has been populated. Every help would be much appreciated.

class PuzzleGame extends Game {
  constructor() {
    super();
    this.rows = 3;
    this.columns = 3;
    //current clicked image, other the one we swap with
    this.currTile;
    this.otherTile;
    this.turns = 0;
    this.imageOrder = [1, 2, 3, 4, 5, 6, 7, 8, 9];
    this.randomOrder = [];
  }
  populateBoard() {
    for (let r = 0; r < this.rows; r++) {
      for (let c = 0; c < this.columns; c++) {
        let tile = document.createElement("img");
        tile.id = r.toString() + "-" + c.toString();
        tile.src = "./images/" + this.randomOrder.shift() + ".png";
        // drag functions
        tile.addEventListener("dragstart", dragStart);
        tile.addEventListener("dragover", dragOver);
        tile.addEventListener("dragenter", dragEnter);
        tile.addEventListener("dragleave", dragLeave);
        tile.addEventListener("drop", dragDrop);
        tile.addEventListener("dragend", dragEnd);

        document.getElementById("board").append(tile);
      }
    }
  }
  _randomizeOrder() {
    if (!this.imageOrder) return undefined;
    this.randomOrder = this.imageOrder.sort(function () {
      return Math.random() - 0.5;
    });
    return this.randomOrder;
  }
  puzzleStart() {
    this._randomizeOrder();
    this.populateBoard();
  }
  dragStart() {
    this.currTile = this; //image being dragged
  }
  dragOver(e) {
    e.preventDefault();
  }
  dragEnter(e) {
    e.preventDefault();
  }
  dragLeave() {}
  dragDrop() {
    this.otherTile = this; //image tile being dropped on
  }
  dragEnd() {
    let currImg = this.currTile.src;
    let otherImg = this.otherTile.src;
    this.currTile.src = otherImg;
    this.otherTile.src = currImg;
  }
}

I tried to assign the addeventlisteners to the tiles of the game while populating the board. In each iteration of the loop I tried to assign the events expecting to populate it AND at the same time painting the image on the board.


问:
Reshape in different array len with NumPy
I have two variables Dog and Face, whose lengths are 921600 and 32256. Then I would like to subtract them as Dog - Face. They gave

ValueError: operands could not be broadcast together with shapes

Is there any possible way to do the subtraction? It's 1D array.

Dog:

```<code>array([136, 173, 215, ..., 209, 214, 217], dtype=uint8)
</code>```

Face:

```<code>array([61.45223488, 62.01139351, 62.26029798, ..., 41.20464505,
       41.97589833, 42.38825592])
</code>```

Body:
I have two variables Dog and Face, whose lengths are 921600 and 32256. Then I would like to subtract them as Dog - Face. They gave

ValueError: operands could not be broadcast together with shapes

Is there any possible way to do the subtraction? It's 1D array.

Dog:

array([136, 173, 215, ..., 209, 214, 217], dtype=uint8)

Face:

array([61.45223488, 62.01139351, 62.26029798, ..., 41.20464505,
       41.97589833, 42.38825592])


问:
Hazelcast Reactive Client
Trying to find hazelcast reactive client to read/update cache.

But don't find any reactive client.

Any sample example is much appreciated.

Thanks & Regards
Ayash Kant Baral

Able to connect with hazelcast server using non reactive client

Title: Hazelcast Reactive Client


问:
Start activities from a fragment
I'm trying to start 3 activities from a fragment through these buttons (btn, btn2, btn3). I do it this way

```<code>class BerandaFragment : Fragment() {

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        val v: View = inflater.inflate(R.layout.fragment_beranda, container, false)

        val listnr: View.OnClickListener = object : View.OnClickListener {
            override fun onClick(v: View?) {
                val intent = Intent(activity, TransaksiActivity::class.java)
                startActivity(intent)
            }
        }
        val listnr2: View.OnClickListener = object : View.OnClickListener {
            override fun onClick(v: View?) {
                val intent2 = Intent(activity, ProdukActivity::class.java)
                startActivity(intent2)
            }
        }
        val listnr3: View.OnClickListener = object : View.OnClickListener {
            override fun onClick(v: View?) {
                val intent3 = Intent(activity, PelangganActivity::class.java)
                startActivity(intent3)
            }
        }
        val btn = v.findViewById<View>(R.id.btntransaksi) as Button
        btn.setOnClickListener(listnr)
        val btn2 = v.findViewById<View>(R.id.btnproduk) as Button
        btn2.setOnClickListener(listnr2)
        val btn3 = v.findViewById<View>(R.id.btnpelanggan) as Button
        btn3.setOnClickListener(listnr3)
        return v
    }

}
</code>```

the first button (btn) worked as it should, but i don't know why the other two didn't. It shows no error, but the app keeps stopping when i press btn2 and btn3

Title: Start activities from a fragment

Body:
I'm trying to start 3 activities from a fragment through these buttons (btn, btn2, btn3). I do it this way

class BerandaFragment : Fragment() {

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        val v: View = inflater.inflate(R.layout.fragment_beranda, container, false)

        val listnr: View.OnClickListener = object : View.OnClickListener {
            override fun onClick(v: View?) {
                val intent = Intent(activity, TransaksiActivity::class.java)
                startActivity(intent)
            }
        }
        val listnr2: View.OnClickListener = object : View.OnClickListener {
            override fun onClick(v: View?) {
                val intent2 = Intent(activity, ProdukActivity::class.java)
                startActivity(intent2)
            }
        }
        val listnr3: View.OnClickListener = object : View.OnClickListener {
            override fun onClick(v: View?) {
                val intent3 = Intent(activity, PelangganActivity::class.java)
                startActivity(intent3)
            }
        }
        val btn = v.findViewById<View>(R.id.btntransaksi) as Button
        btn.setOnClickListener(listnr)
        val btn2 = v.findViewById<View>(R.id.btnproduk) as Button
        btn2.setOnClickListener(listnr2)
        val btn3 = v.findViewById<View>(R.id.btnpelanggan) as Button
        btn3.setOnClickListener(listnr3)
        return v
    }

}

the first button (btn) worked as it should, but i don't know why the other two didn't. It shows no error, but the app keeps stopping when i press btn2 and btn3


问:
Why an ArrayList Type of the object does not support the size() method which is a builtin method for the ArrayList Type Object?
The entire question is in java. I am trying to extract some information from a json data format, then I used an mapper object to

```<code>data = mapper.readValue(jsonData, new TypeReference<>(){});
</code>```

to convert this into a List of HashMaps, in fact, printing data.get(0).getClass() gives me as an LinkedHashMap, when I run data.get(0).get("key")  returns as an ArrayList, but when I do ```
data.get(0).get("key").size()</p>
```

It complains, can anyone point out why and provide me any suggestion on how to get the associated values from the key?
```

Body:
The entire question is in java. I am trying to extract some information from a json data format, then I used an mapper object to

data = mapper.readValue(jsonData, new TypeReference<>(){});

to convert this into a List of HashMaps, in fact, printing data.get(0).getClass() gives me as an LinkedHashMap, when I run data.get(0).get("key")  returns as an ArrayList, but when I do ```
data.get(0).get("key").size()

It complains, can anyone point out why and provide me any suggestion on how to get the associated values from the key?